如果有人能够MagicalRecord
与AFIncrementalStore
一起使用,请解释如何一起使用它们?
我正在尝试将MagicalRecord
配置为使用AFIncrementalStore
但是当我提取获取请求时,应用会挂起。我可以看到AFIncrementalStore
向API服务器发出请求并接收响应,但之后UI变得没有响应。
以下是MagicalRecord + AFIncrementalStore
的配置:
NSManagedObjectModel *model = [NSManagedObjectModel MR_defaultManagedObjectModel];
NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
AFIncrementalStore *incrementalStore = (AFIncrementalStore *)[persistentStoreCoordinator addPersistentStoreWithType:[APIIncrementalStore type] configuration:nil URL:nil options:nil error:nil];
NSDictionary *options = @{
NSInferMappingModelAutomaticallyOption : @(YES),
NSMigratePersistentStoresAutomaticallyOption: @(YES)
};
[incrementalStore.backingPersistentStoreCoordinator MR_addSqliteStoreNamed:@"DB.sqlite" withOptions:options];
[NSPersistentStore MR_setDefaultPersistentStore:incrementalStore];
[NSPersistentStoreCoordinator MR_setDefaultStoreCoordinator:incrementalStore.persistentStoreCoordinator];
[NSManagedObjectContext MR_initializeDefaultContextWithCoordinator:incrementalStore.persistentStoreCoordinator];
获取请求如下所示:
[Card MR_fetchAllSortedBy:@"number" ascending:YES withPredicate:nil groupBy:nil delegate:self];