我想将当前日期存储到核心数据中。该实体被称为具有多个属性(浮点数)和名为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