iphone Core数据保存时出现未解决的错误 [英] iphone Core Data Unresolved error while saving

查看:135
本文介绍了iphone Core数据保存时出现未解决的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试保存
时,我收到来自核心数据的奇怪错误消息,但是错误不可重现的问题(在执行不同任务时出现在不同时间)

I am getting a strange error message from the core data when trying to save but the problem that the error is not reproducible ( it appears at different times when doing different tasks)

错误讯息:

Unresolved error Domain=NSCocoaErrorDomain Code=1560 UserInfo=0x14f5480 "Operation could not be completed. (Cocoa error 1560.)", {
NSDetailedErrors = (
Error Domain=NSCocoaErrorDomain Code=1570 UserInfo=0x5406d70 "Operation could not be completed. (Cocoa error 1570.)",
Error Domain=NSCocoaErrorDomain Code=1570 UserInfo=0x14f9be0 "Operation could not be completed. (Cocoa error 1570.)"
);
}

,生成错误的方法是:

- (IBAction)saveAction:(id)sender {
    NSError *error;
    if (![[self managedObjectContext] save:&error]) {
        // Handle error
        NSLog(@"Unresolved error %@, %@, %@", error, [error userInfo],[error localizedDescription]);
        exit(-1);  // Fail
    }
}

此邮件的原因?

推荐答案

这意味着有一个强制属性已被赋值为nil。在您的* .xcodatamodel中检查可选框,或当您保存到managedObjectContext时,请确保您的属性已填写。

It means there's a mandatory property has been assigned nil. Either in your *.xcodatamodel check the "optional" box or when you are saving to the managedObjectContext make sure that your properties are filled in.

如果您进一步错误,更改您的代码后,以适应这两个要求尝试清除您的构建和删除从iPhone模拟器/ iPhone设备的应用程序。您的模型更改可能会与旧模型实施冲突。

If you're getting further errors after changing your code to suit the two requirements try cleaning your build and delete the application from your iPhone Simulator/iPhone device. Your model change may conflict with the old model implementation.

编辑:

我几乎忘了这里的所有错误Core Data发出的代码:
核心数据常量参考
我之前遇到过麻烦,我意识到我取消选中正确的可选框。这样的麻烦找出问题。祝你好运。

I almost forgot here's all the error codes that Core Data spits out: Core Data Constants Reference I had trouble with this before and I realised I unchecked the correct optional box. Such trouble finding out the problem. Good luck.

这篇关于iphone Core数据保存时出现未解决的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆