iOS iTunes FileSharing不起作用

时间:2017-06-02 14:37:15

标签: iphone xcode8 ios10.3

我正在尝试使用iTunes FileSharing保存mp3铃声文件,但它不起作用。所有mp3文件都存储在支持文件下。

NSString *fileName = @"demo.mp3";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *m4rPath = [documentsDirectory stringByAppendingPathComponent:fileName];
NSFileManager *fileManager = [NSFileManager defaultManager];

NSError *err = nil;
[fileManager copyItemAtPath:filePath toPath:[m4rPath stringByAppendingPathComponent:fileName] error:&err];
        NSLog(@"%@",[err localizedDescription]);

任何帮助都将受到高度赞赏

1 个答案:

答案 0 :(得分:0)

最后!!我已经解决了。我在复制文件时犯了愚蠢的错误。

[fileManager copyItemAtPath:filePath toPath: m4rPath error:&err];