2011-11-08 25 views
4

鑑於以下控制檯輸出,爲什麼我的Core Data保存失敗? 看來biz實體是空的。我有20個「biz」實體,只有1個很可能是空的。爲什麼整個保存失敗?爲什麼Core Data不保存所有的工作並忽略空實體?

爲什麼不核心數據只是保存所有的工作,並忽略空實體?相反,它返回Error in saving Error in Saving Error Domain=NSCocoaErrorDomain Code=1570

這裏是我的控制檯日誌:

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.)} 
+0

可能重複(HTTP ://stalkoverflow.com/questions/1283960/iphone-core-data-unresolved-error-while-saving) – Moshe

回答

4

previous answer最能解釋它。引用接受的答案:

這意味着有一個強制性的財產已被分配零。無論是在 你* .xcodatamodel檢查「可選」對話框,或當您保存到 的managedObjectContext確保您的屬性填寫。

[同時節省了iPhone核心數據未解決錯誤]的
+1

我知道。但是,如果我想節省100個工作人員,其中一個工作人員無法驗證,那麼爲什麼其他人不能得救? –

+1

因爲它沒有。我完全同意它應該 - 但這不是它的工作原理。如果你希望它能像那樣工作,那麼你應該提交一個錯誤報告,或者使該屬性可選,並實現一個自定義的保存方法,以滿足你的需求。 – sosborn

+0

不,我只是想確保它是這樣的:)。這很令人驚訝。它說它以那種方式工作?當然我可以一個一個保存。 –

相關問題