[NSArray filteredAraryUsingPredicate:] performance?
[NSArray filteredAraryUsingPredicate:] performance?
- Subject: [NSArray filteredAraryUsingPredicate:] performance?
- From: Abhi Beckert <email@hidden>
- Date: Fri, 22 Oct 2010 13:19:22 +1000
Hi,
I have this code:
- (NSArray *)products
{
if (products)
return products;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"visible = 1"];
products = [[self.category.products allObjects] filteredArrayUsingPredicate:predicate];
return [products retain];
}
I'm using the result of this method to populate a UITableView, and in this case — don't need to worry about performance or memory consumption — as there won't ever be many products per category. This is nice simple code — much simpler than the NSFetchedResultsController code I'm using elsewhere (where the UITableView might contain a lot of data).
My question is, at what point do I decide to swap between a simple array of objects and a full fetched results controller? How much does performance/memory suffer from using filteredArrayUsingPredicate? My time is billed by the hour, and we have trouble finding skilled programmer staff in our regional city, so anywhere I can save 20 minutes will translate into real benefits to our clients (in terms of price and completion times, and even whether or not we will take on their project at all).
- Abhi_______________________________________________
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