ios - How to deleteAllObjects from NSSet -


i have method here counts number of annotations on map view. however, every time method called, anncount keeps on incrementing. example, there 5 annotations on map - first time method called returns 5 expected. second time it's called returns 11, 16, 21, 26 , on..

mkmaprect visiblemaprect = mymapview.visiblemaprect; nsset *visibleannotations = [mymapview annotationsinmaprect:visiblemaprect]; anncount = [visibleannotations count];   nslog(@"%u", anncount); return anncount; 

i thinking if clear objects nsset work properly. however, nsset won't recognise deleteallobjects. have tried nsmutableset doesn't work "annotationsinmaprect:visiblemaprect". cheers.

your problem not nsset returned. problem annotationsinmaprect: returning more objects expected. leads me believe add more , more annotations map (perhaps mistake).

nsset immutable collection, cannot add or remove objects instance. more, when visibleannotations released, releases objects in it. since annotationsinmaprect: returns new object, not matter if able call removeallobjects.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -