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

我是研究僧i 提交于 2020-01-02 02:33:27

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/31067989/osstatus-error-2003334207-while-re-buiding-the-app-from-xcode-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!