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: Sherm Pendley <email@hidden>
- Date: Thu, 13 May 2004 13:57:59 -0400
On May 13, 2004, at 12:23 PM, 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)?
That depends on the method you want to call. If the method takes no
argument, you can use NSArray's -makeObjectsPerformSelector: method. If
it takes a single id argument, you can use
-makeObjectsPerformSelector:withObject:.
If you want to call a method that has more and/or differently-typed
arguments, or if you need to pass a different value to each object in
the array, you'll need to use a loop.
sherm--
_______________________________________________
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.