Tôi đang cố cập nhật MKMapView bằng cách xóa tất cả các chú thích bên ngoài vùng hiển thị và thêm và xóa một số chú thích bên trong vùng hiển thị. Đây là mã của tôi:NSSet để NSArray gọi đối tượng castingAtIndex?
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];
này mang lại cho tôi những lỗi - [__ NSCFSet objectAtIndex:]: chọn không được công nhận gửi đến dụ 0x13cd40 sau dòng cuối cùng mà tôi đúc newAnnotations đến một NSArray sau đó thêm các chú thích. Có một cái gì đó về việc đúc một mảng đến một bộ gây ra điều này? Nếu vậy, có cách nào làm tròn nó không?
allObjects thay đổi thứ tự.So objectAtIndex có thể không trả về dự định. – Vignesh
@Vignesh Non sequitur. Một bộ không được đặt hàng. –
Giải pháp được đề xuất ở đây không hiệu quả đối với tôi ...'[theNSSet allObjects]' chỉ cần thêm NSSet như một đối tượng bên trong một NSArray, đó là một thất bại, bởi vì tôi không cần một NSSet INSIDE một NSArray, tôi cần một NSArray FROM nội dung của NSSet –