我想將當前日期存儲到核心數據中。該實體被稱爲具有多個屬性(浮點數)和名爲timeStamp(日期)的屬性的情緒。 float屬性沒有錯。但是,當我試圖保存日期是這樣的:商店中的錯誤NSdate在coredata
emotionAppDelegate * appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *emotion =
[appDelegate managedObjectContext];
NSManagedObject *newEmotions;
newEmotions = [NSEntityDescription
insertNewObjectForEntityForName:@"Emotions"
inManagedObjectContext:emotion];
[newEmotions setValue:[NSData data] forKey:@"timeStamp"];
我得到了一個錯誤:
2012-11-25 21:03:09.130 silder[4634:c07] Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" UserInfo=0x8174b20 {metadata={
NSPersistenceFrameworkVersion = 419;
NSStoreModelVersionHashes = {
Emotions = <c8b9e393 5624a477 dee1958e 19dd1209 acb67cd9 56daefea dbf8bfc9 daa8e34d>;
};
NSStoreModelVersionHashesVersion = 3;
NSStoreModelVersionIdentifiers = (
""
);
NSStoreType = SQLite;
NSStoreUUID = "5CE10BB2-A77A-4E8B-AAE6-5973000DFADA";
"_NSAutoVacuumLevel" = 2;
},原因=與一個用於創建存儲用於開實體店的模式是不兼容},{ 元數據= {NSPersistenceFrameworkVersion = 419; NSStoreModelVersionHashes = { Emotions =; }; NSStoreModelVersionHashesVersion = 3; NSStoreModelVersionIdentifiers =( 「」 ); NSStoreType = SQLite; NSStoreUUID =「5CE10BB2-A77A-4E8B-AAE6-5973000DFADA」; 「_NSAutoVacuumLevel」= 2; }; reason =「用於打開商店的模型與用於創建商店的模型不兼容」; }
任何人都可以幫助我嗎?非常感謝你!
謝謝!但是我得到了一個新的錯誤:終止應用程序由於未捕獲的異常'NSInvalidArgumentException',原因:'不可接受的屬性類型的值:屬性=「timeStamp」;期望的類型= NSDate;給定類型= NSConcreteData;值= <>。' – lancellx
更好地設置屬性類型爲NSDate – aahsanali
[newEmotions setValue:[NSData data] forKey:@「timeStamp」];我想我創建它作爲NSDate .. – lancellx