I am struggling with deleting sphere objects and its children (and children) RLMArray!
The following figure shows the current area structure (Realm-Browser screenshot):

As you can see, three RLMTopoResult objects are currently created, each of which has 86 RLMCriteria as a child array. (What is not visible is that each of these RLMCriteria has its own RLMStatistics-Array - so there are as many RLMStatistics objects as RLMCriteria objects).
Now the idea is to remove one RLMTopoResult (with a predictor that filters according to TopoNrRLM)!
I apply the following code:
- (void) removeObjects_at_TopoNr_from_LocationRLM :(NSUInteger)TopoNr :(NSString *)folderName :(NSString *)fileName { RLMRealm *realm = [RLMRealm realmWithPath:[self get_TopoResultRLM_FilePath :folderName :fileName]]; RLMResults *resultTopoResult = [RLMTopoResult allObjectsInRealm:realm]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"TopoNrRLM == %d", TopoNr]; RLMResults *resultsTopoNr = [resultTopoResult objectsWithPredicate:predicate]; if ([resultsTopoNr count] > 0) { if (TopoNr <= (int)[resultsTopoNr count]) { [realm beginWriteTransaction]; [realm deleteObject:[resultsTopoNr firstObject]]; [realm commitWriteTransaction]; } else { NSLog(@"Fail...trying to remove TopoResult-object with TopoNr bigger to object-count"); } } else { NSLog(@"Fail...trying to remove TopoResult-object in empty Realm"); } }
Running the above method with TopoNr = 2 removes (as expected) RLMTopoResult Nr2 (see the figure below) → But, unfortunately, it does not delete its Array-Children (and children) !!! After removing RLMTopoResult-Nr2, there is 3x86 = 258 RLMCriteria (as well as 258 RLMStatistics). But the expected will be 2x86 = 172 !!!!
What can I do to automatically also remove children of 86 RLMCriteria (and its 86 RLMStatistics) attached to the corresponding RLMTopoResult?
Any help appreciated!
The following figure shows the result after removing TopoResult Nr2 (with the code above): (it is expected that we will have 172 RLMCriteria instead of 258! ... what else is wrong? ...)

source share