0
的想法是導入服務器JSON響應爲核心的數據,而不在主線程阻塞UI,我還需要輸入的實體之後,一整個上午測試後/谷歌搜索,我沒有找到正確的方法來做到這一點。神奇的記錄,如何使用saveWithBlock和仍然可以訪問導入的數據之後
__block NSMutableArray *cars;
[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
for (NSDictionary *carObject in carObjects) {
Notification *car = [Notification MR_importFromObject:carObject inContext:localContext];
[cars addObject:car];
}
} completion:^(BOOL success, NSError *error) {
if (success) {
for (Car *car in cars) {
// data may have invalid data or be nil
// [Car findAll] will have correct data though
}
}
}];