在RealmCocoa的示例项目中:
// Multi-threading
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
RLMRealm *otherRealm = [RLMRealm defaultRealm];
RLMResults *otherResults = [Dog objectsInRealm:otherRealm where:@"name contains 'Rex'"];
NSLog(@"Number of dogs: %li", (unsigned long)otherResults.count);
});
在网站文档中:
dispatch_async(dispatch_queue_create("background", 0), ^{
@autoreleasepool {
Dog *theDog = [[Dog objectsWhere:@"age == 1"] firstObject];
RLMRealm *realm = [RLMRealm defaultRealm];
[realm beginWriteTransaction];
theDog.age = 3;
[realm commitWriteTransaction];
}
});
发布于 2017-11-14 07:30:51
https://stackoverflow.com/questions/47276936
复制相似问题