I use the AVAssetExportSession to export mp3/m4a files in ipod library. This method works well on iOS 5.0 and earlier. However after upgrade iOS to 5.1, this method doesn\'t
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);
}