0

私は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

だから、私のコードに適用される提案とソースコードを教えてください

4

1 に答える 1

1

NSURLの現在のドキュメントには、「fileURLWithPath:error:」などのメソッドがリストされていません...非推奨か間違っているようです。

代わりに、次のようなものを使用してみてください。

[NSURL fileURLWithPath:audioList]

それが役に立てば幸い...

于 2012-07-14T09:54:01.277 に答える