该操作无法完成。 (可可错误516.)

时间:2012-07-09 10:14:43

标签: ios database sqlite copy

-(void) checkAndCreateDatabase{

BOOL success;

NSFileManager *fileManager = [NSFileManager defaultManager];

success = [fileManager fileExistsAtPath:databasePath];

if(success) return;

NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:databaseName];


 NSError *errr;

 [fileManager copyItemAtPath:databasePathFromApp toPath:databasePath error:&errr];

 NSLog( @"Error >>>>>>>> %@",errr);

}

使用上面的代码数据库文件在iOS 5.0模拟器中创建,但是没有sql查询。 如果使用iOS 4.3模拟器,它可以正常工作。运行te app时显示以下错误。

Error >>>>>>>> Error Domain=NSCocoaErrorDomain Code=516 "The operation couldn’t be completed. (Cocoa error 516.)" UserInfo=0x6a53860 {NSUserStringVariant=(
Copy
), NSFilePath=/Users/sj/Library/Application Support/iPhoneSimulator/5.0/Applications/D8BF5CC1-5690-4897-A3D7-252D915D399E/MyTest.app/MyTestDB.sql, NSDestinationFilePath=/Users/sj/Library/Application Support/iPhone Simulator/5.0/Applications/D8BF5CC1-5690-4897-A3D7-252D915D399E/Documents/MyTestDB.sql, NSUnderlyingError=0x6a65510 "The operation couldn’t be completed. File exists"}

0 个答案:

没有答案