1
執行取回在後臺請求這是我到目前爲止有:使用MagicalRecord
NSManagedObjectContext *privateContext = [NSManagedObjectContext MR_context];
[privateContext performBlock:^{
Cat* object = [Cat MR_findFirstByAttribute:@"id" withValue:catId inContext:privateContext];
// Convert your fetched objects into object IDs which can be pulled out of the main context
NSString *privateObjectID = [object valueForKey:@"objectID"];
// Return to our main thread
dispatch_async(dispatch_get_main_queue(), ^{
???
});
}];
這是應該做的事情嗎?如果是這樣,我怎麼讓我的對象回到主線程? (在上面的???區)
如果我只是這樣做:
NSManagedObjectContext* context = [NSManagedObjectContext MR_contextForCurrentThread];
Cat* object = [Cat MR_findFirstByAttribute:@"id" withValue:catId inContext:context];
的UI被阻塞,所以我試圖找出如何做到不阻塞主線程的獲取。