0
我想將文件從應用程序NSBundle複製到Documents目錄。將文件從NSBundle複製到文檔錯誤
如何過我不能得到這個代碼的工作:
-(NSString*)copyFile:(NSString*)name{
NSString *storePath = [[[appDelegate applicationDocumentsDirectory] absoluteString] stringByAppendingPathComponent:name];
NSError *error;
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"recordTest" ofType:@"caf"];
if (defaultStorePath) {
if ([fileManager fileExistsAtPath:defaultStorePath]) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:&error];
NSLog(@"Error: %@)" , [error localizedDescription]);
}
}
}
return storePath;
}
該打印操作無法完成。
的詳細信息:
Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be completed. (Cocoa error 4.)" UserInfo=0xd629530 {NSUserStringVariant=(
Copy
), NSFilePath=/var/mobile/Applications/D0183043-3FD2-4341-8DA4-E1D140E556F6/test.app/recordTest.caf, NSDestinationFilePath=file:/localhost/var/mobile/Applications/D0183043-3FD2-4641-8DA4-E5D140E556F6/Documents/recordTest.caf, NSUnderlyingError=0xd629970 "The operation couldn’t be completed. No such file or directory"}
我不明白爲什麼有沒有這樣的文件,如果我複製前檢查。
任何想法?
感謝