Re: Obj-C idioms for list based tasks
Re: Obj-C idioms for list based tasks
- Subject: Re: Obj-C idioms for list based tasks
- From: Erik Buck <email@hidden>
- Date: Mon, 7 Apr 2008 10:51:33 -0700 (PDT)
This is a prime use for Higher Order messaging:
http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf
http://www.cocoadev.com/index.pl?HigherOrderMessaging
http://www.oreilly.com/pub/a/mac/2004/07/16/hom.html
HOM takes this
// which of these employee objects earn more than 1000 Euros.
int i;
id salariedEmployees = [NSMutableArray array];
for (i = 0 ; i < [employees count] ; i++ )
{
id employee = [employees objectAtIndex: i ];
if ( [employee hasSalary: 1000] )
{
[salariedEmployees addObject: employee];
}
}
and turns it into this
salaried=[[employees select] hasSalary: 1000] ;
_______________________________________________
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