我創建了處理聲音的類。但我有阻止聲音的問題?我無法將變量從playSound發送到stopSound AudioServicesDisposeSystemSoundID(soundID)。 如何處理?我真的不想實例化它或我必須?靜態方法變量問題
@implementation SoundPlayer
+(void)playSound:(NSString *)filename ofType:(NSString *)extension {
SystemSoundID soundID;
NSString *soundFile = [[NSBundle mainBundle] pathForResource:filename ofType:extension];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundFile], &soundID);
AudioServicesPlaySystemSound(soundID); // error - soundID is undeclared
}
+(void)stopSound
{
AudioServicesDisposeSystemSoundID(soundID);
}
@end
,我怎麼能聲明靜態PARAM? – alexhajdu
'@interface TheClass:NSObject +(int)count; @ end'參見:http://stackoverflow.com/questions/6035824/objective-c-static-class-variables – cleverbit