0
我是iOS開發新手,想知道是否有人可以幫我理解爲什麼這會起作用? @synthesize是做什麼的?試圖瞭解iOS開發中的AVAudioPlayer
在.H
@property (strong, nonatomic) AVAudioPlayer *player;
在.M
@synthesize player;
-(void)startMusic{
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"audio" ofType:@"m4a"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.numberOfLoops = -1; //infinite
[player play];
}
確實如此,謝謝! – Chris
沒問題:)很高興我可以得到一些幫助 – user2277872