问题
I am trying to save a mp3 file into a folder where the file could be visible in iTunes Library. I read somewhere that if I save it on NSDocumentDirectory, it would work, but I had no luck on trying that.
I also tried NSMusicDirectory and NSLibraryDirectory.
this is how I'm saving it:
NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDirectory = [documentPath objectAtIndex:0];
NSString *savePath = [docDirectory stringByAppendingPathComponent:@"file.mp3"];
[_oneNSDataFile writeToFile:savePath atomically:YES];
thanks for your time!
回答1:
Sorry, bad news :) The iPod Library Access API in iOS doesn't allow third party apps to modify the contents of the user's music library. In addition to that, adding a media file into the library directory won't work, because the library uses a (binary) index file to determine the contents of the library, and the locations of the media assets.
回答2:
try saving files to NSMusicDirectory .
来源:https://stackoverflow.com/questions/5097332/ios-saving-audio-file-visible-in-itunes-library