0

I'm trying to compare two sets of RMAnnotations (Annotations used in the MapBox SDK for iOS), using the following code:

 NSMutableSet *before = [NSMutableSet setWithArray:self.mapboxView.annotations];

if(self.mapboxView.userLocation)
    [before removeObject:[self.mapboxView userLocation]];

NSSet *after = [NSSet setWithArray:annotations];

NSMutableSet *toKeep = [NSMutableSet setWithSet:before];
[toKeep intersectSet:after];
NSLog(@"to keep %lu", (unsigned long)toKeep.count);

NSMutableSet *toAdd = [NSMutableSet setWithSet:after];
[toAdd minusSet:toKeep];
NSLog(@"to add %lu", toAdd.count);

Which works great in MKMapKit for MKAnnotations, but has no effect in MapBox. Would anybody have any idea why this might be the case?

Thanks!

trdavidson
  • 1,051
  • 12
  • 25
  • @incanus - would appreciate your input – trdavidson May 25 '15 at 14:50
  • This should work, but it depends on what `toKeep` looks like, of course. `RMAnnotations` are just concrete objects. Could you show some annotation creation code? – incanus May 26 '15 at 15:33
  • @incanus - fixed it, had to override isEqual() and hash() to make a deep comparison. The other issue I'm running into now, is that when I have a large number of pins on the map, and manually try to drop another Array of annotations, only the first one is added to the map. Any idea out of the top of your head what might cause such behaviour? Thanks – trdavidson May 26 '15 at 17:02

0 Answers0