get error code -11843 while exporting mp3 file in ipod library since iOS 5.1

Finally found a workaround.

Use AVAssetExportSession to export but append “.mov” at the end of export url.
This should make AVAssetExportSession successfully export the song.
Last step, rename the exported file with NSFileManager, remove the “.mov” at end.

To rename a file saved in documents directory, you can use NSFileManager as below:

NSString *exportFile = ... //.. path of saved *.mov file in documents directory
NSString *newPath = [[exportFile stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"newFileName.mp3"];

NSError *renameError = nil;
[[NSFileManager defaultManager] moveItemAtPath:exportFile toPath:newPath error:&renameError];

if (renameError) {
    NSLog (@"renameError=%@",renameError.localizedDescription);
}else {
    NSLog (@" No renameError(Success) :: newPath=%@",newPath);
}

Leave a Comment