2012-04-09 77 views
0

我對核心數據相當陌生,並且遇到問題。我的應用程序目前非常簡單。我有一個用戶名單和一個電子郵件。該應用程序啓動並通過核心數據NSFetchedRequest從本地數據庫中提取所有用戶。該應用程序目前可以創建,讀取和刪除而不會出錯。我遵循關於核心數據的蘋果教程。更新核心數據中的對象導致應用程序崩潰

我遇到的問題是保存編輯的用戶。當點擊用戶時,會顯示編輯視圖控制器,其中人員可以編輯該特定用戶的用戶名和電子郵件。當我去更新並保存用戶時,應用程序崩潰。錯誤是:

2012-04-09 17:47:09.757 SEA[7032:fb03] CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. [ valueForUndefinedKey:]: the entity User is not key value coding-compliant for the key "timeStamp". with userInfo { NSTargetObjectUserInfoKey = " (entity: User; id: 0x880ec10 ; data: {\n email = \"[email protected]\";\n username = sampleUser1;\n})"; NSUnknownUserInfoKey = timeStamp; } 2012-04-09 17:47:09.760 SEA[7032:fb03] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ valueForUndefinedKey:]: the entity User is not key value coding-compliant for the key "timeStamp".'

從錯誤的外觀上來看,它仍然能看到屬性的timeStamp即使我刪除了歸屬。 用戶實體是想以下幾點:

#import <Foundation/Foundation.h> 
#import <CoreData/CoreData.h> 


@interface User : NSManagedObject 

@property (nonatomic, retain) NSString * username; 

@property (nonatomic, retain) NSString * email; 

@end 

如果有人能幫我,我會真正體會到它。

+0

向我們展示你的數據模型文件。 – borrrden 2012-04-09 23:30:57

+0

我的數據模型文件包含如果一個實體:用戶,用戶名:字符串和電子郵件:字符串作爲屬性。這就是全部 – Ishikawa 2012-04-09 23:43:52

回答

0

如果您剛剛編輯了Apple示例代碼,有沒有提及更新名爲timeStamp的屬性。

做一個項目範圍內尋找timeStamp並酌情更新(例如,你不是在你的模型中使用它刪除任何提及)

+0

哦,你的救星!在MasterViewController中調用了使用關鍵timeStamp的configureWithCell。我沒有想到在那裏看,因爲我沒有在任何地方使用該控制器,但一些默認代碼調用該視圖控制器。再次感謝。 – Ishikawa 2012-04-09 23:56:42

相關問題