I had code in a old sdk 3.0 project of mine that is not working with the new sdk. I have copied the code in a very simple project (just a uivue project and I put the sound code in onload) to make sure nothing else I did is messing it up.
I’m getting a error code -46, Domain NSOSStatusErrorDomain
code
- (void)viewDidLoad
{
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"EvilDrop-2.mp3",
[[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.volume=1.0;
audioPlayer.numberOfLoops= 0;
[audioPlayer play];
audioPlayer.delegate = self;
}
That’s because you’re not using
-[NSString stringWithFormat:correctly. However, you don’t need that method.Try this code: