4

Given the following console output, why is my Core Data save failing? It seems that the biz entity is empty. I have 20 "biz" entities, and only 1 is most likely empty. Why does the whole save fail?

Why doesn't Core Data just save all that works and ignore the empty entity? Instead, it returns Error in saving Error in Saving Error Domain=NSCocoaErrorDomain Code=1570.

Here's my console log:

2011-11-08 11:37:49.059 BadgerNew[3808:4503] <0x38a520 GrabClass.m:(509)> Biz to save <Business: 0x32e2550> (entity: Business; id: 0x32b7dd0 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255489> ; data: {
    Bookmark = 0;
    Building = nil;
    City = "0x32f06e0 <x-coredata:///City/t069264E3-D89C-4D4A-92D9-8A190B7CF255396>";
    Distance = "484.0799568283629";
    Districts =     (
        "0x326b7a0 <x-coredata:///District/t069264E3-D89C-4D4A-92D9-8A190B7CF255398>"
    );
    Email = nil;
    ID = 22302;
    Images =     (
        "0x32df100 <x-coredata:///Image/t069264E3-D89C-4D4A-92D9-8A190B7CF255494>"
    );
    InBuildingAddress = "Blok De Unit 1-2";
    LatitudeLongitude = "0x32755f0 <x-coredata:///LatitudeLongitude/t069264E3-D89C-4D4A-92D9-8A190B7CF255495>";
    Like = 0;
    OpeningHour = nil;
    Phones =     (
        "0x32def60 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255493>",
        "0x32e2d60 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255490>",
        "0x32dea90 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255491>",
        "0x32decb0 <x-coredata:///Phone/t069264E3-D89C-4D4A-92D9-8A190B7CF255492>"
    );
    Price = 0;
    Promotions =     (
    );
    Rating = "0x3275000 <x-coredata:///Rating/t069264E3-D89C-4D4A-92D9-8A190B7CF255496>";
    Reviews =     (
    );
    Street = "Jl. Panjang Kedoya No. 1";
    Tags =     (
    );
    TimeStamp = nil;
    Title = "Bank BNI Graha Elok Mas";
    URLs =     (
    );
    Website = nil;
    Zip = 11520;
    pinAndLineNumber = 0;
})
2011-11-08 11:37:49.095 BadgerNew[3808:4503] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x31fbd0 {NSValidationErrorObject=<Business: 0x328c660> (entity: Business; id: 0x332840 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255441> ; data: {
    Bookmark = 0;
    Building = nil;
    City = nil;
    Distance = "-1";
    Districts =     (
    );
    Email = nil;
    ID = "";
    Images =     (
    );
    InBuildingAddress = nil;
    LatitudeLongitude = nil;
    Like = 0;
    OpeningHour = nil;
    Phones =     (
    );
    Price = 0;
    Promotions =     (
    );
    Rating = nil;
    Reviews =     (
    );
    Street = nil;
    Tags =     (
    );
    TimeStamp = nil;
    Title = nil;
    URLs =     (
    );
    Website = nil;
    Zip = nil;
    pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
2011-11-08 11:37:51.307 BadgerNew[3808:1403] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x322ca30 {NSValidationErrorObject=<Business: 0x323f510> (entity: Business; id: 0x323f6a0 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF25511> ; data: {
    Bookmark = 0;
    Building = nil;
    City = nil;
    Distance = "-1";
    Districts =     (
    );
    Email = nil;
    ID = "";
    Images =     (
    );
    InBuildingAddress = nil;
    LatitudeLongitude = nil;
    Like = 0;
    OpeningHour = nil;
    Phones =     (
    );
    Price = 0;
    Promotions =     (
    );
    Rating = nil;
    Reviews =     (
    );
    Street = nil;
    Tags =     (
    );
    TimeStamp = nil;
    Title = nil;
    URLs =     (
    );
    Website = nil;
    Zip = nil;
    pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
2011-11-08 11:37:53.284 BadgerNew[3808:1b03] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x3a4c90 {NSValidationErrorObject=<Business: 0x32aee0> (entity: Business; id: 0x300480 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255220> ; data: {
    Bookmark = 0;
    Building = nil;
    City = nil;
    Distance = "-1";
    Districts =     (
    );
    Email = nil;
    ID = "";
    Images =     (
    );
    InBuildingAddress = nil;
    LatitudeLongitude = nil;
    Like = 0;
    OpeningHour = nil;
    Phones =     (
    );
    Price = 0;
    Promotions =     (
    );
    Rating = nil;
    Reviews =     (
    );
    Street = nil;
    Tags =     (
    );
    TimeStamp = nil;
    Title = nil;
    URLs =     (
    );
    Website = nil;
    Zip = nil;
    pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
2011-11-08 11:37:56.480 BadgerNew[3808:4403] <0x427c0 TreadClass.m:(82)> Error in Saving Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0x3c5e10 {NSValidationErrorObject=<Business: 0x32d4530> (entity: Business; id: 0x3d0240 <x-coredata:///Business/t069264E3-D89C-4D4A-92D9-8A190B7CF255296> ; data: {
    Bookmark = 0;
    Building = nil;
    City = nil;
    Distance = "-1";
    Districts =     (
    );
    Email = nil;
    ID = "";
    Images =     (
    );
    InBuildingAddress = nil;
    LatitudeLongitude = nil;
    Like = 0;
    OpeningHour = nil;
    Phones =     (
    );
    Price = 0;
    Promotions =     (
    );
    Rating = nil;
    Reviews =     (
    );
    Street = nil;
    Tags =     (
    );
    TimeStamp = nil;
    Title = nil;
    URLs =     (
    );
    Website = nil;
    Zip = nil;
    pinAndLineNumber = 0;
}), NSValidationErrorKey=Title, NSLocalizedDescription=The operation couldn’t be completed. (Cocoa error 1570.)}
wixardy
  • 35
  • 1
  • 5
user4951
  • 32,206
  • 53
  • 172
  • 282
  • possible duplicate of [iphone Core Data Unresolved error while saving](http://stackoverflow.com/questions/1283960/iphone-core-data-unresolved-error-while-saving) – Moshe Nov 08 '11 at 04:58

1 Answers1

4

This previous answer explains it best. To quote from the accepted answer:

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.

Community
  • 1
  • 1
sosborn
  • 14,676
  • 2
  • 42
  • 46
  • 1
    I know. But if I want to save 100 bizs and one of them doesn't validate, why the rest don't get saved? – user4951 Nov 10 '11 at 04:34
  • 1
    Because it doesn't. I totally agree that it should - but that just isn't how it works. If you want it to work like that then you should file a bug report, or make that property optional and implement a custom will save method that does what you need. – sosborn Nov 10 '11 at 04:40
  • No. I just want to make sure that it's the way it is :). It's surprising. Where does it says that it works that way? Of course I can save one by one. – user4951 Nov 10 '11 at 09:11