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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to