的醫生說:關於objectWithID的好處:
If the object is not registered in the context, it may be fetched or returned as a fault. This method always returns an object. The data in the persistent store represented by objectID is assumed to exist—if it does not, the returned object throws an exception when you access any property (that is, when the fault is fired). The benefit of this behavior is that it allows you to create and use faults, then create the underlying data later or in a separate context.
我想最後一句:
The benefit of this behavior is that it allows you to create and use faults, then create the underlying data later or in a separate context.
這是否意味着我可以使用objectWithID:
與任意ID
獲得先存在一個不存在對象的錯誤句柄,然後用ID
創建對象?但是,我怎樣才能將一個任意的ID
分配給新的對象?
如果保存收到的對象會發生什麼情況? – Wain
您可以正常保存,但沒有任何意義。在下面看到我自己的答案。 – an0