OSStatus error 2003334207 when restoring an application from Xcode 6

I use AVAudioPlayer to play the recorded sound that is saved in the Iphone document directory. When I first record the sound and then play it works fine (the device is connected to the system, and the application runs through Xcode).

But when I stop running the application through Xcode and running the application again through Xcode, I get Error Error Domain=NSOSStatusErrorDomain Code=2003334207 "The operation couldn't be completed. (OSStatus error 2003334207.)"

File location: file:///var/mobile/Containers/Data/Application/410AB24E-5FB0-4401-AC59-3C03D676E951/Documents/26-06-2015--13:10:47.m4a

My code is:

 fileLocation = @"file:///var/mobile/Containers/Data/Application/410AB24E-5FB0-4401-AC59-3C03D676E951/Documents/26-06-2015--13:10:47.m4a" NSURL *fileUrl = [NSURL URLWithString:fileLocation]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error]; [player setDelegate:self]; NSURL *fileUrl = [NSURL URLWithString:fileName]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error]; [player setDelegate:self]; 

I am using Xcode 6 and running the application on iOS 8

PS: I read so many documents related to this problem, as well as several questions in the statckoverflow file itself, but I did not find the answer.

+8
ios xcode6 avaudioplayer
source share
1 answer

In iOS8, the path you saved will not be valid at launch time. The identifier that you see, "410AB24E-5FB0-4401-AC59-3C03D676E951" will change every time it starts.

The solution is to save the file name, not the full path, and also restore the URL or the full path by going to the Documents (or tmp) folder and adding the file name to it.

+14
source share

All Articles