0

I have a table view managed by a NSFetchedResultsController. The entries correspond to certain Annotations on a map. The table view itself can be sorted in different ways. So when the user deletes a particular row in this table I want the annotation on the map to be removed. Since I cannot use the index of the table row in the fetchedObjects array I'm a bit lost. I wanted to subclass now the MKPointAnnotation Object and add one property of the type of my POI=Point of Interest class. However I don't know if I'm able to basically look in the annotations array if any POI property matches the POI object just being deleted?

MichiZH
  • 5,587
  • 12
  • 41
  • 81

1 Answers1

1

You have a few options. You can sort your array of annotations using a custom comparator. That way you can just use the index path to delete items. That method is described here: How to sort an NSMutableArray with custom objects in it?

The other option is you can give the cell a reference to the annotation and on deletion just delete that annotation.

Another option is that you can loop through the array and check the condition yourself. On an unsorted collection with no hash or index, this really the only other option.

Community
  • 1
  • 1
InkGolem
  • 2,662
  • 1
  • 15
  • 22