-(void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"MathMusic2" ofType:@"wav"];
self.theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL]
autorelease]; //error: expected ';' before 'autorelease' and // error: expected statement before ']' token
theAudio.delegate = self;
[theAudio play];
theAudio.numberOfLoops = -1;
}
相關的警告:
warning: property 'theAudio' requires method '-theAudio' to be defined - use @synthesize, @dynamic or provide a method implementation
warning: property 'theAudio' requires the method 'setTheAudio:' to be defined - use @synthesize, @dynamic or provide a method implementation
告訴我,如果你需要的.h編碼。但那裏沒有錯誤。
屬性是使用@屬性關鍵字在'@ interface'塊中聲明的東西。它基本上是一些語法糖,所以你可以使用'object.theAudio'和'object.theAudio = value'這樣的語法,而不是'[object theAudio]'和'[object setTheAudio:value]'。 – Anomie 2011-04-23 15:26:26
是的,非常感謝你們。這真的有幫助 – user722566 2011-04-23 15:37:38