我希望在我的iPhone应用程序中使用Core Data。
该应用程序实际上不需要存储所使用的数据,但需要进行管理和查询。
是否可以使用Core Data来处理仅存在于内存中且未持久化到磁盘的数据集?
我希望在我的iPhone应用程序中使用Core Data。
该应用程序实际上不需要存储所使用的数据,但需要进行管理和查询。
是否可以使用Core Data来处理仅存在于内存中且未持久化到磁盘的数据集?
当然可以,只需将存储类型设置为NSInMemoryStoreType。 更具体地说,您可以像这样设置:
NSError *error = nil;
//Ignore that it is called an "NSPersistentStore", it is not persisted
NSPersistentStore *inMemoryStore = [persistentStoreCoorindator addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:&error];
if (inMemoryStore && !error) {
//It is setup
}