Использовать IBOutlet в функции в заголовочном файле - PullRequest
1 голос
/ 02 марта 2011

Подскажите, пожалуйста, как я могу использовать IBOutlets в функции, хранящейся в заголовочном файле:

.h файл:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>    

@interface MainView : UIView <AVAudioPlayerDelegate>  {

        IBOutlet UILabel *SoundDescriptionLabel;
    IBOutlet UIBarButtonItem *StopSoundButton;

}
- (IBAction)PlayFatGuyWalking:(id)sender;
- (IBAction)PlayRoadRunner:(id)sender;
- (IBAction)ShowInfoPopup:(id)sender;
- (IBAction)PlayChaosRunning:(id)sender;
- (IBAction)PlaySadTrombone:(id)sender;
- (IBAction)PlayBadJokeSound:(id)sender;
- (IBAction)PlayHorrorSynth:(id)sender;
- (IBAction)PlayLKWPeep:(id)sender;
- (IBAction)PlayUiToll:(id)sender;
- (IBAction)StopSound:(id)sender;



AVAudioPlayer *theAudio;



@end


//PlaySound Function
void playSound(NSString *filename,NSString *type){
    [theAudio stop];    
    NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:type];
    theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
//HERE I WOULD LIKE TO DO THIS:
StopSoundButton.enabled=1;
//END OF WHAT I'D LIKE TO DO
        [theAudio play];
    }

Пожалуйста, помогите мне

спасибо заранее

1 Ответ

1 голос
/ 02 марта 2011

IBOutlet не влияет и не влияет на ваш код - он # определен!

Он используется в качестве подсказки для Interface Builder, который может анализировать заголовок, чтобы он знал, что эта переменная может каким-то образом связываться с некоторым графическим элементом управления.

...