Blog of Tejas Shirodkar

NSArray lastIndexOf / NSMutableArray lastIndexOf

by on Jun.09, 2013, under Development

I couldn’t find any pre existing way of getting the last index of an item in NSArray, so I ended up creating my own implementation.

Categories are a very cool feature of objective C and allow you to add functionality to pre-existing classes in a modular way.

After including the category as part of the build, a developer can simply import the category header and use lastIndexOf as it was part of NSArray or NSMutableArray.

[NSArray lastIndexOf:(id)anObject];
[NSMutableArray lastIndexOf:(id)anObject fromIndex:(NSUInteger)fromIndex];

Just add the following two files to your project and you are all set.

(continue reading…)

Leave a Comment : more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!