Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @interface ModelA : RLMObject
- @property int pk;
- @end
- @implementation ModelA
- + (NSString *) primaryKey
- {
- return @"pk";
- }
- @end
- @implementation ViewController
- {
- RLMNotificationToken *_nfA;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- RLMRealm *realm = [RLMRealm defaultRealm];
- [realm beginWriteTransaction];
- for(int i = 0; i<10; ++i)
- {
- ModelA *a = [[ModelA alloc] init];
- a.pk = i;
- [realm addOrUpdateObject:a];
- }
- [realm commitWriteTransaction];
- _nfA = [[ModelA allObjects] addNotificationBlock:^(RLMResults *results, RLMCollectionChange *change, NSError *error)
- {
- if(change)
- {
- NSLog(@"Insertions: %lu deleteions:%lu modifications:%lun", change.insertions.count, change.deletions.count, change.modifications.count);
- }
- }];
- for(int i=0; i<10; ++i)
- {
- RLMRealm *realm = [RLMRealm defaultRealm];
- [realm beginWriteTransaction];
- [realm deleteObject:[[ModelA allObjects] objectAtIndex:0]];
- [realm commitWriteTransaction];
- }
- }
- @end
- 2017-01-20 10:44:19.394 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.395 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.395 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.396 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.396 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.397 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.397 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.397 Test[7536:12871658] Insertions: 1 deleteions:2 modifications:0
- 2017-01-20 10:44:19.398 Test[7536:12871658] Insertions: 0 deleteions:1 modifications:0
- 2017-01-20 10:44:19.402 Test[7536:12871658] Insertions: 0 deleteions:1 modifications:0
- _nfA = [[[ModelA allObjects] sortedResultsUsingKeyPath:@"pk" ascending:NO] addNotificationBlock:...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement