terminating app due to uncaught exception

Hi,


i am displaying annotations on a map and since i am using a lot of annotations i am using two methods to reduce the load on the program.

First of all i have a basic clusterAnnotation method.

Second i am removing all the annotations not shown on the screen and as soon as the user pans it updates this amount of displayed annotations.

This works fine with about 20 annots, but as soon as i add about 300 the program gives me a signal SIGABRT error in the appDelegate as well as this error:

" *** Terminating due to uncaught exception 'NSInvalidArgumentException', reason: '-[Project1.customAnnotation memberAnnotation]: unrecognized selector sent to instance 0x6000014062e0' ".


i looked for "memberAnnotation" in every class but couldn't find anything.


This is my customAnnotation class:

class customAnnotation: MKPointAnnotation {
     var setNeedsToggle = false
     
     var adress: String?
     var info1: Float?
     var info2: Float?
     var info3: Float?
     var info4: Float?

     var icon: String = " "
}



Ok First Update:

tested it again on an actual iphone and the following problem occured:


this is the function removing all the annotations not displayed on the screen:

func updateAnnotations(for region: MKCoordinateRegion) {
     let visRect = mapView.visibleMapRect
     let keepAnnotations = mapView.annotations(in: visRect)
     var removeAnnotations = mapView.annotations

     removeAnnotations.removeAll(where: {
          if let annotation = $0 as? AnyHashable {
               return keepAnnotations.contains(annotation)
          }
          return false
     })

     mapView.removeAnnotations(removeAnnotations)
}

Now on line 13 it gives me a "EXC_BAD_ACCESS"-error


Now i tried it again and this time its again the Signal SIGABRT error in the AppDelegate


No idea what's going on?!


Thanks a lot,

Gus