问题是是否将CoreData与Reskit一起使用,这是因为我不知道使用此工具有什么好处,或者建议在哪种情况下使用它。

这个问题是因为我有一个使用CoreData的应用程序(老开发人员完成了这项工作),并且我觉得它消耗了大量资源,并使该应用程序运行缓慢。

我有一个新闻提要,所以这里的数据总是在变化,所以我不需要保留我认为的数据?但是我有一些对象,例如我的个人资料图片和我想存储在本地的首选项。

*更新*

这是定义“持久性”的代码(我认为)

NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
    RKObjectManager* man = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:BASE_URL]];
    man.requestSerializationMIMEType = RKMIMETypeJSON;
    [RKObjectManager setSharedManager:man];

    [AFNetworkActivityIndicatorManager sharedManager].enabled = YES;

    RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
    man.managedObjectStore = managedObjectStore;

    //configuring Mappings
    /**some mappings**/

    [managedObjectStore createPersistentStoreCoordinator];
    NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Database.sqlite"];
    NSError *error;
    NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:nil withConfiguration:nil options:nil error:&error];
    NSAssert(persistentStore, @"Failed to add persistent store with error: %@", error);

    // Create the managed object contexts
    [managedObjectStore createManagedObjectContexts];

    // Configure a managed object cache to ensure we do not create duplicate objects
    managedObjectStore.managedObjectCache = managedObjectStore.managedObjectCache;

最佳答案

使用核心数据。还要看看使用提取的结果控制器(以管理数据存储中数据页的批量加载)。这对于一个新闻源应用程序是完美的,其中您可能会有相对大量的源文件项目,但是一次都不会显示很多(因此您不需要它们在内存中)。使用原始SQLite或磁盘上文件中的数据来自己管理此问题将需要更多工作,并且性能可能会降低。

关于ios - Restkit是否支持CoreData,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19777436/

10-13 06:35