我是 iPhone 开发的初学者。我要播放声音。所以,这就是我应用此代码的原因
(void)viewDidLoad
{
NSError* err;
path=[[NSBundle mainBundle] pathForResource:@"Animalfile" ofType:@"plist"];
dict=[NSDictionary dictionaryWithContentsOfFile:path];
NSArray *animalaudio=[dict valueForKey:@"audio"];
NSString *audiolist=[animalaudio objectAtIndex:currentsound];
AVAudioPlayer *audio=[[AVAudioPlayer alloc]initWithContentsOfURL:[NSURL fileURLWithPath:audiolist error:&err]];
audio.delegate=self;
[audio play];
}
我得到了运行时错误
[NSURL fileURLWithPath:error:]: unrecognized selector sent to class 0x182121c
2012-07-14 14:51:21.711 plistdemo[1236:10703] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '+[NSURL fileURLWithPath:error:]:
unrecognized selector sent to class 0x182121c'
terminate called throwing an exceptionsharedlibrary apply-load-rules all
所以,给出适用于我的代码的任何建议和源代码