2009-12-18 28 views
1
NSError *error = nil; 

NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy]; 

if (mutableFetchResults == nil) 
    { 
     // Handle the error. 
    } 

// Set self's events array to the mutable array, then clean up. 
[self setEventsArray:mutableFetchResults]; 
[mutableFetchResults release]; 

這些代碼給出了運行時錯誤 「executeFetchRequest:error:獲取請求必須有一個實體」。 任何人都可以幫助解決這個錯誤executeFetchRequest:錯誤

回答

5

是的,但你需要發佈代碼實際創建提取請求,因爲該錯誤消息相當準確地表明你沒有正確配置提取請求。

特別是,您需要在提取請求上調用setEntity:

另外,創建一組提取請求的可變副本是非典型的。相反,只需將對象的提取結果設置爲返回的數組(或數組的-copy - 不可變的不可變數組副本基本上是免費的)。

相關問題