简体   繁体   English

如何解决运行时错误'无法创建带有消息的可写数据库文件'无法完成操作。 (可可错误260.)'。'?

[英]how to solve run time error 'Failed to create writable database file with message 'The operation couldn’t be completed. (Cocoa error 260.)'.'?

I am beginner of iPhone I have created database but that give run time error of Failed to create writable database file with message 'The operation couldn't be completed 我是iPhone的初学者我已经创建了数据库,但是给出了运行时错误,无法创建可写数据库文件并显示消息'操作无法完成

my code is 我的代码是

-(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]);  
        }

    }
}

give any suggestion and source code which is apply in my code 提供适用于我的代码的任何建议和源代码

I have done little google for this error code and I found that 我为这个错误代码做了一点谷歌,我发现了

NSFileReadNoSuchFileError = 260,                        // Read error (no such file)

So, please make sure that DB file(SQL.sqlite) is there on path by which you are referring in your above snippet. 因此,请确保您在上述代码段中引用的路径中存在DB文件(SQL.sqlite)。

试试这个:从模拟器的应用程序文件夹中删除应用程序,然后再次运行应用程序。我刚做完这个小工作,我的错误就是..祝你好运..

If Shah Paneri's answer does not work for you you can additionally look at your database file's "Target Membership". 如果Shah Paneri的答案对您不起作用,您还可以查看您的数据库文件的“目标成员资格”。 Be sure that your project is selected. 确保选择了您的项目。 If it is not (as mine was not), selecting this should fix the problem. 如果不是(因为我的不是),选择这个应该解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决的运行时错误,操作无法完成。 (OSStatus错误-43。)? - how to solve run time error of The operation couldn’t be completed. (OSStatus error -43.)? 该操作无法完成。 可可错误4 - The operation couldn’t be completed. Cocoa Error 4 该操作无法完成。 (可可错误1560.) - The operation couldn’t be completed. (Cocoa error 1560.) 该操作无法完成。 (可可错误:3840。) - The Operation couldn't be completed. (Cocoa error: 3840.) “这项行动无法完成。 (可可错误512.)“ - “The operation couldn’t be completed. (Cocoa error 512.)” 无法保存到数据存储:无法完成操作。 (可可错误133020.) - Failed to save to data store: The operation couldn’t be completed. (Cocoa error 133020.) 如何解决错误:操作无法完成。 (可可错误3840。)json iOS? - How to resolve error:the operation couldn’t be completed. (cocoa error 3840.) json iOS? 错误域= NSCocoaErrorDomain代码= 3840“操作无法完成。(可可错误3840.) - Error Domain = NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.) iOS - Twitter连接问题:“操作无法完成。 (可可错误3840.)“ - iOS - Twitter Connectivity Issue: “The operation couldn’t be completed. (Cocoa error 3840.)” 该操作无法完成。 (可可错误3840。)”(在字符16周围的对象中没有键值。) - The operation couldn’t be completed. (Cocoa error 3840.)" (No value for key in object around character 16.)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM