永久存储是否是iPhone上核心数据的要求?

Jas*_*ien 7 iphone persistence core-data

我想在我的iPhone应用程序中使用Core Data.

该应用程序并不真正需要存储使用的数据,但需要进行管理和查询.

核心数据可以用于纯粹存在于内存中并且不会持久存储到磁盘的数据集吗?

Lou*_*arg 18

当然,只需将商店类型设置为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
}
Run Code Online (Sandbox Code Playgroud)