可視領域外のすべての注釈を削除し、可視領域内のいくつかの注釈を追加および削除して、MKMapView を更新しようとしています。これは私のコードです:
NSSet *visibleAnnotations = [mapView annotationsInMapRect:[mapView visibleMapRect]];
NSSet *allAnnotations = [NSSet setWithArray:[mapView annotations]];
NSMutableSet *nonVisibleAnnotations = [NSMutableSet setWithSet:allAnnotations];
[nonVisibleAnnotations minusSet:visibleAnnotations];
[mapView removeAnnotations:(NSArray *)nonVisibleAnnotations];
NSMutableSet *newAnnotations = [NSMutableSet setWithArray:[_zoomLevels objectAtIndex:clusterLevel]];
[newAnnotations minusSet:visibleAnnotations];
[mapView addAnnotations:(NSArray *)newAnnotations];
これにより、-[__NSCFSet objectAtIndex:]: unrecognized selector sent to instance 0x13cd40というエラーが表示されます。newAnnotationsを NSArray にキャストしてから注釈を追加する最後の行の後にあります。これを引き起こすセットに配列をキャストすることについて何かありますか? もしそうなら、それを回避する方法はありますか?