| Article: |
Higher-Order Messages in Cocoa | |
| Subject: | Let HOM be your mantra | |
| Date: | 2005-06-23 01:14:50 | |
| From: | DanD. | |
|
Response to: Let HOM be your mantra
|
||
|
Just wondering, if superHeros is an array, why not just use
|
||
Showing messages 1 through 2 of 2.
-
Let HOM be your mantra
2005-06-23 01:17:49 DanD. [Reply | View]
-
Let HOM be your mantra
2005-06-23 16:40:08 georgerix [Reply | View]
(I'm posting from my Dad's account for the moment--apologies for any confusion this causes.)
There really is no problem with makeObjectsPerformSelector:; it's a handy mechanism to have when you need to perform an operation over an array. However, it doesn't yield the full flexibility of a mechanism such as blocks or trampolines, whereby you can define methods (like collect, select, reject, and detect) which return (and in the case of detect, operate) differently.
makeObjectsPerformSelector: is more or less equivalent, when combined with its siblings which take further arguments to use, to the HOM method do, but more complex uses require invocations... trampolines and HOM are basically a system to make invocations automatically-- that is, to make them conveniently.
As much as anything else, it's a matter of style.
Thanks for the comments!




[superHeros makeObjectsPerformSelector:@selector(saveTheDay)];
etc. Sorry for not proofreading.
-Dan