我正在通過向它添加2000條記錄來測試Realm。問題在於,當我停止運行應用程序時,即使任何行都沒有執行,deleteAllObject方法也不會調用。我認爲問題在beginWriteTransaction方法中。Realm在停止運行應用程序後無法工作?
這是我的代碼:
RLMRealm *realm = [RLMRealm defaultRealm];
[realm beginWriteTransaction];
[realm deleteAllObjects];
[realm commitWriteTransaction];
for (int i = 0 ; i < 2000; i++) {
[realm beginWriteTransaction];
PeopleInformation *info = [[PeopleInformation alloc] init];
info.name = [NSString stringWithFormat:@"%@ %d",@"Rohit",i];
info.city = @"Delhi";
[realm addObject:info];
[realm commitWriteTransaction];
}
NSLog(@"all object %@", [PeopleInformation allObjects]);
你是什麼意思'問題是,當我停止運行應用程序...'?你是否明確地試圖在執行中斷程序? – TiM