Re: Calling a method on objects in an NSArray
Re: Calling a method on objects in an NSArray
- Subject: Re: Calling a method on objects in an NSArray
- From: Marcel Weiher <email@hidden>
- Date: Fri, 14 May 2004 12:17:06 +0100
On 13 May 2004, at 19:01, Allan Odgaard wrote:
On 13. May 2004, at 18:23, David Piasecki wrote:
Is it possible, as in some other languages, to call a method on all
objects in an array via one line of code (no loops)?
You can do:
[array makeObjectsPerformSelector:@selector(action)];
HOM:
[[array do] action];
Or (to "collect" the results):
NSArray* res = [array valueForKey:@"action"];
HOM:
NSArray *res = [[array collect] action];
Also:
NSArray *res = [[array select] __hasPrefix:@"NS"];
NSArray *res = [[array selectWhereValueForKey:@"ClassName"]
__hasPrefix:@"NS"];
HOM is available as part of MPWFoundation,
http://www.metaobject.com
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.