2010-06-09 52 views
4

從文檔:-existingObjectWithID:錯誤:這是文檔中的錯誤嗎? -existingObjectWithID:錯誤:或-objectWithID:似乎要求不同的東西不符合

If there is a managed object with the given ID already registered in the context, that object is returned directly; otherwise the corresponding object is faulted into the context.

This method might perform I/O if the data is uncached.

Unlike objectWithID:, this method never returns a fault.

那麼,這是悖論!

他們說,-existingObjectWithID:錯誤:可能會返回一個錯誤(「故障進入上下文」)。與此同時,他們說-objectWithID:確實會返回一個錯誤,但是-existingObjectWithID:error:不會。那麼現在呢?這兩種方法描述都討論了返回故障對象。

有人可以清除嗎?

+0

無需兩次發佈此問題。 http://stackoverflow.com/questions/3006394/ – Emil 2010-06-09 14:13:26

+0

@Emil - 這不是重複的。它提出了一個相關但不同的問題。 – TechZen 2010-06-09 21:04:43

+0

@Tech同時發佈? – Emil 2010-06-09 21:16:52

回答

11

故障並不意味着「成爲故障」。它實際上意味着,「創造一個完全成熟的物體」與你期望的相反。換句話說,故障對象不是故障。命名混亂。

它是由於從舊的DB日中「發生故障」一詞而產生的。在這個術語中,你犯了一個錯誤,即一個對象的鬼魂,並「解僱」它,從而導致它加載它的屬性。這從「解決問題」縮短爲「天真的」,幼稚的讀者/聽衆會認爲這意味着「成爲過錯」。

在培訓中,我使用「鬼」這個詞作爲斷層的同義詞,並將「物化」用於斷層。它有助於清除術語並同時表達我童年時代對Scooby-Do的熱愛。

相關問題