Cocoa - Enumerate mutable array, removing objects

Posted by Ward on Stack Overflow See other posts from Stack Overflow or by Ward
Published on 2010-03-27T17:42:48Z Indexed on 2010/03/27 17:53 UTC
Read the original article Hit count: 544

Hey there,

I have a mutable array that contains mutable dictionaries with strings for the keys latitude, longitude and id. Some of the latitude and longitude values are the same and I want to remove the duplicates from the array so I only have one object per location.

I can enumerate my array and using a second enumeration review each object to find objects that have different ids, but the same latitude and longitude, but if I try to remove the object, I'm muting the array during enumeration.

Is there any way to remove objects from an array while enumerating so I only enumerate the current set of objects as the array is updated?

Hope this question makes sense.

Thanks, Howie

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about enumerate