What do you want to achieve?
What did you expected to happen?
What did happened instead?
e.g. the stack trace of a crash
What are steps we can follow to reproduce this issue?
Provide a code sample or test case that highlights the issue.
If relevant, include your model definitions.
For larger code samples, links to external gists/repositories are preferred.
Alternatively share confidentially via mail to [email protected].
Full Xcode projects that we can compile ourselves are ideal!
In the CONTRIBUTING guidelines, you will find a script,
which will help determining these versions.
Realm version: 0.98.6
Xcode version: 9.3
iOS/OSX version: ios
Dependency manager + version: cocopod 1.0bate
RMUserInfo *rm_userInfo = [[RMUserInfo alloc] initWithWKUserInfo:userInfo];
[kRealmManager transactionWithBlock:^{
[kRealmManager deleteObject:rm_userInfo];
}];
。。。。。。。。。
// cheeseBook stored in Realm
// Delete an object with a transaction
[realm beginWriteTransaction];
[realm deleteObject:cheeseBook];
[realm commitWriteTransaction];
I'll have to table to find object by ID ??
According to the primary key can be deleted??
//RMUserInfo *rm_userInfo = [[RMUserInfo alloc] initWithWKUserInfo:userInfo];
RLMResults *results = [RMUserInfo objectsWhere:[NSString stringWithFormat:@"userId == '%@'", userInfo.userId]];
//primaryKey: @"userId"
RMUserInfo *rm_userInfo = results.lastObject;
[kRealmManager transactionWithBlock:^{
[kRealmManager deleteObject:rm_userInfo];
}];
This is right
but deleted a object by primary key ?
@menhui222 Use objectForPrimaryKey: method to retrieve object by primary key. Then pass the object to the deleteObject: method. So the idiom for deleting by primary key is like the following:
[realm deleteObject:[RMUserInfo objectForPrimaryKey:primaryKey]];
thank you!
Most helpful comment
@menhui222 Use
objectForPrimaryKey:method to retrieve object by primary key. Then pass the object to thedeleteObject:method. So the idiom for deleting by primary key is like the following: