无法将文件从主包复制到iPad上的文档目录
|
我从这里的其他花粉中找到了这段代码。它在iPad模拟器模式下可以正常工作,但是当我切换到实际的iPad设备模式时却无法正常工作。相反,它提出了“不存在这样的文件”错误消息。在执行此代码之前,我确实通过右键单击xxxxxx.app创建了Populator文件夹,然后选择\“ show package contents \”并将一些文件放入Populator文件夹。 Xcode是否可以在iPad设备上复制整个应用程序包?有什么建议么?
NSString *documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *sourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@\"Populator\"];
NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@\"Files\"];
NSLog(@\"Source Path: %@\\n Documents Path: %@ \\n Folder Path: %@\", sourcePath, documentsDirectory, folderPath);
NSLog(@\"docdire: %@\", documentsDirectory);
NSLog(@\"loadImage button clicked\");
label.text = [@\"sourcePath: \" stringByAppendingString:sourcePath];
textField.text = [@\"clicked: \" stringByAppendingString:documentsDirectory];;
NSError *error;
if([[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:folderPath error:&error]){
NSLog(@\"File successfully copied\");
label.text = @\"copy succeeded\";
} else {
NSLog(@\"Error description-%@ \\n\", [error localizedDescription]);
NSLog(@\"Error reason-%@\", [error localizedFailureReason]);
label.text = [@\"Error description: \" stringByAppendingString:[error localizedDescription]];
label2.text = [@\"Error reason: \" stringByAppendingString:[error localizedFailureReason]];
}
没有找到相关结果
已邀请:
3 个回复
岭取
剃摧庭峨僳
遣莫捅炭