-1
有没有什么方法可以找出createOrUpdateInRealm
方法是否插入新对象?通过在领域createOrUpdateInRealm查找是否有新对象
RLMRealm *realm = [RLMRealm defaultRealm];
SampleRealmObject *object = [[SampleRealmObject alloc] init];
NSDictionary *item = @{@"id": @10, @"name": @"sampleName"};
for (RLMProperty *property in object.objectSchema.properties) {
if([item objectForKey:property.name])
{
[object setValue:[item objectForKey:property.name] forKey:property.name];
}
}
// add or update the new object
[SampleRealmObject createOrUpdateInRealm:realm withValue:object];
使用'id'获取对象,如果不存在则使用'add'或使用'update'。 –
@SachinVas我知道这种方法,但我会问这个方法可能给我们的东西。 –