Reputation: 20965
I wonder if it is supported to pass RLMObjects without Realm between threads... it makes kind of sense, because otherwise you wouldn't be able to fetch them in main thread...
But thats a bit in controversy that the Realm object cannot be passed between threads
I tried it and it looks working.... but would welcome a deep opinion on this
[self.operationQueue addOperation:[NSBlockOperation blockOperationWithBlock:^{
RLMObject * object = [[resultClass alloc] initWithValue:dictionary];
[[NSOperationQueue mainQueue] addOperation:[NSBlockOperation blockOperationWithBlock:^{
// add object to default realm
RLMRealm * realm = [RLMRealm defaultRealm];
[realm beginWriteTransaction];
[realm addObject:object];
[realm commitWriteTransaction];
}]];
}]];
Upvotes: 0
Views: 673
Reputation: 8138
Objects which have not been added to a Realm (and were not read from a Realm) are just normal NSObjects, so it's fine to pass them between threads.
Upvotes: 1