从内存中通过标示符找到 RLMRealm实例
<code>
+(instancetype)inMemoryRealmWithIdentifier:(NSString *)identifier;
</code>
示例代码:
<code>
RLMRealm *memRlm = [RLMRealm inMemoryRealmWithIdentifier:NvrFileRLMIdentifier];
rlmToken = [memRlm addNotificationBlock:^(NSString *notification, RLMRealm *realm){
[self flushData];
[_camListTableView reloadData];
}];
</code>
关于一对多
<code>
@interface Person : RLMObject
@property NSString *name;
@property NSData *picture;
@property RLMArray *dogs;
</code>
关于开启写入事物写入
一、
<code>
RLMRealm *realm = [RLMRealm defaultRealm];
[realm transactionWithBlock:^{
_ipcamModel.cacheImgPath = spath;
}];
</code>
二、
<code>
[[RLMRealm defaultRealm] beginWriteTransaction];
_ipcamModel.cacheImgPath = spath;
[[RLMRealm defaultRealm] commitWriteTransaction];
</code>
关于查询
一 谓词查询
<code>
RLMRealm *memRLM = [RLMRealm defaultRealm];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"uid = %@", uid];
RLMResults *needNvr = [NvrModel objectsInRealm:memRLM withPredicate:pred];
NvrModel *nvr = [needNvr lastObject];
</code>
二条件查询
<code>
RLMResults *r = [Dog objectsWhere:@"age > 8"];
// Queries are chain able 这个单词不认识
r = [r objectsWhere:@"name contains 'rex'"];
</code>
跨线程
<code>
dispatch_async(dispatch_queue_create("background", 0), ^{
RLMResults *results = [Dog objectsWhere:@"name contains 'rex'"];
});
</code>