如何在保存时调试CoreData崩溃?

Jos*_*ane 0 iphone cocoa-touch core-data objective-c ipad

我正在尝试使用Coredata在我的应用程序中保存我的对象但是我遇到了崩溃并且这个非常令人困惑的错误:

Unresolved error Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x2f8820 {NSValidationErrorObject=<ContactInfo: 0xf081140> (entity: ContactInfo; id: 0x20c0f0 <x-coredata:///ContactInfo/tDCD050E6-3BA3-47D2-A5ED-A22D53749E4B7> ; data: {
    addressLine1 = nil;
    addressLine2 = nil;
    email = nil;
    mobileNo = nil;
    name = nil;
    phoneNo = nil;
    stateCounty = nil;
    townCity = nil;
    venue = nil;
    zipIp = nil;
}), NSValidationErrorKey=name, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}, {
    NSLocalizedDescription = "The operation couldn\U2019t be completed. (Cocoa error 1570.)";
    NSValidationErrorKey = name;
    NSValidationErrorObject = "<ContactInfo: 0xf081140> (entity: ContactInfo; id: 0x20c0f0 <x-coredata:///ContactInfo/tDCD050E6-3BA3-47D2-A5ED-A22D53749E4B7> ; data: {\n    addressLine1 = nil;\n    addressLine2 = nil;\n    email = nil;\n    mobileNo = nil;\n    name = nil;\n    phoneNo = nil;\n    stateCounty = nil;\n    townCity = nil;\n    venue = nil;\n    zipIp = nil;\n})";
}
Run Code Online (Sandbox Code Playgroud)

ContactInfo是我核心数据模型中的一个实体,我有另一个名为VenueInfo的实体,每个对象都有一个ContactInfo对象,因为每个场所都需要联系人详细信息.如果错误消息不够,我会添加一些代码和更多细节.

Jos*_*ane 7

原来这个关键的一点信息:

NSValidationErrorKey=name

属性的手段name,这是一个验证问题,这是因为,直到现在,我的核心数据模型中的这个属性不是可选的,如图所示返回nil导致崩溃.

通过给出name值或使其成为可选来避免崩溃.