Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess what you're looking for is :</p> <pre><code>- (NSSet *)annotationsInMapRect:(MKMapRect)mapRect </code></pre> <p>Quoting <a href="http://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html#//apple_ref/occ/instm/MKMapView/annotationsInMapRect%3a" rel="nofollow">Apple documentation</a> :</p> <blockquote> <p>This method offers a fast way to retrieve the annotation objects in a particular portion of the map. This method is much faster than doing a linear search of the objects in the annotations property yourself.</p> </blockquote> <p>Take care that's it's only <em>Available in iOS 4.2 and later</em>, I'm afraid there is no other solution than custom code in previous iOS versions.</p> <p><strong>EDIT</strong> About your comment : My guess is that for a few thousands annotation, the above method <em>should</em> do the trick, <code>MKAnnotation</code> is a lightweight protocol, scanning an array by filtering on coordinate should be ok. But beware on not adding thousands of <code>MKAnnotationView</code>, that works on an iPhone 4, already did it, but you almost can't scroll map :)</p> <p>Then I would suggest :</p> <ol> <li>Use that method, quick to code, easy, then do some performance tests, <em>on device</em></li> <li>If performances are not enough.... or you have to support prevous iOS versios, no magic, write you own code. (shouldn't be that hard, there are utility methods for converting regions and such)</li> </ol> <p>About memory, hey, these devices have easily at least 64MB free memory for your app, and will kill some processes if not, don't be scared by a few K of annotations! Just take care of memory leaks, especially on such intensive processes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload