Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSStatus error 2003334207 while re-buiding the App from Xcode 6

I am using AVAudioPlayer to play recorded audio which is saved in Iphone's Document directory. When I first record an audio and then play, it works fine (Device is connected to the system and App is running through Xcode).

But when I Stop the running App through Xcode and again run the App through Xcode, I am getting 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:

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 App in IOS 8

P.S: I have read so many documentations related to this issue and also several questions in statckoverflow itself, but I didn't find the answer.

like image 717
Atul Khanduri Avatar asked Jun 26 '15 07:06

Atul Khanduri


1 Answers

Under iOS8, the path that you have saved won't be valid across launches. The id you see "410AB24E-5FB0-4401-AC59-3C03D676E951" will change with each launch.

The solution is to save the filename and not the complete path, and to recreate the URL or complete path, by getting the path to the Documents (or tmp) folder and appending the filename to it.

like image 122
mahboudz Avatar answered Jan 02 '23 15:01

mahboudz