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

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

问题描述

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

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
    }
}

对此消息的原因有什么想法吗?让它出现在随机时间

any idea for the reason of this message ? giving that it appears at random times

推荐答案

表示有一个强制属性被赋值为 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核心数据未解决错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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