![](/img/trans.png)
[英]how to solve run time error of The operation couldn’t be completed. (OSStatus error -43.)?
[英]how to solve run time error 'Failed to create writable database file with message 'The operation couldn’t be completed. (Cocoa error 260.)'.'?
我是iPhone的初學者我已經創建了數據庫,但是給出了運行時錯誤,無法創建可寫數據庫文件並顯示消息'操作無法完成
我的代碼是
-(void)createdatabase
{
NSFileManager *fileManager=[NSFileManager defaultManager];
NSError *error;
NSString *dbPath=[self getDBPath];
BOOL success=[fileManager fileExistsAtPath:dbPath];
if(!success)
{
NSString *defaultDBPath=[[[NSBundle mainBundle]resourcePath] stringByAppendingPathComponent:@"SQL.sqlite"];
success=[fileManager copyItemAtPath:defaultDBPath toPath:dbPath error:&error];
if(!success)
{
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
}
提供適用於我的代碼的任何建議和源代碼
我為這個錯誤代碼做了一點谷歌,我發現了
NSFileReadNoSuchFileError = 260, // Read error (no such file)
因此,請確保您在上述代碼段中引用的路徑中存在DB文件(SQL.sqlite)。
試試這個:從模擬器的應用程序文件夾中刪除應用程序,然后再次運行應用程序。我剛做完這個小工作,我的錯誤就是..祝你好運..
如果Shah Paneri的答案對您不起作用,您還可以查看您的數據庫文件的“目標成員資格”。 確保選擇了您的項目。 如果不是(因為我的不是),選擇這個應該解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.