Re: Finding object array index when iterating through array
Re: Finding object array index when iterating through array
- Subject: Re: Finding object array index when iterating through array
- From: Daniel Vollmer <email@hidden>
- Date: Thu, 08 Mar 2012 16:11:14 +0100
On 7 Mar 2012, at 12:09, John Maisey wrote:
> Hi,
>
> If the items are unique, how about:
>
> [array indexOfObject:object];
Congratulations, you have just (depending on NSArray-implementation details) "improved" your loop from from O(N) to O(N^2). Don't do this.
> Using a counter is likely be faster though.
Correct.
Daniel.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden