I am developing an application that involves clicking a button repeatedly, and I am giving an audio feedback for this click, a click wave file.
it works fine, but I have a problem, after exactly 248 times, the sound is not played any more, the app doesn't crash however. and I get the following error:
Error Domain=NSOSStatusErrorDomain Code=-43 "The operation couldn't be completed. (NSOSStatusErrorDomain error -43.)"
here is the code I am using, (pretty standard)
//file.h
AVAudioPlayer *audioPlayer;
//file.m
NSString *path=[[NSBundle mainBundle] pathForResource:@"click" ofType:@"wav"];
[audioPlayer stop]; //I added this in one of my trials to solve it.
audioPlayer= [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:&err];
audioPlayer.numberOfLoops=0;
audioPlayer.delegate=self;
[audioPlayer prepareToPlay];
if (audioPlayer==nil)
NSLog(@"%@, %@",path,[err description]);
else
[audioPlayer play];
any idea why this happens?