Method selectors and parameter passing
Method selectors and parameter passing
- Subject: Method selectors and parameter passing
- From: Oliver Donald <email@hidden>
- Date: Mon, 9 Dec 2002 11:42:23 -0000
As a learning experiment I am writing a program that uses Genetic Algorithms
to modify images. What I would like to do is to define the 'genes' (i can
never remember what a single element of a sequence is called :o) as being
commands in a scripting language. So there is a gene for the method
()GaussianBlur, another for ()SwapColorComponents and so on.
In C I would have done this by having each gene contain a function pointer,
so the parsing and execution of an entire genome would be something like:
for (index = 0; index < genomeLength; index ++)
{
(genomeList[index])(myImage);
}
In objective C, I assume this kind of thing would be possible with method
selectors? The problem I have is that I am not sure how to deal with
parameter passing. A function like ()DoGaussianBlur requires one param for
the radius, something like ()FindEdges doesn't require any, and something
like ()DrawBox requires many.
Basically I need to know how I can store NSArray's of selectors + their
parameters for variable-lenght parameter lists . Can anyone provide pointers
(no pun intended) to how I could implement the above C in Objective-C? Is
there a better way to do this?
Thanks,
Oli
DISCLAIMER: The information contained in this e-mail is confidential and may
be privileged. It is intended for the addressee only. If you are not the
intended recipient, please delete this e-mail immediately.
The contents of this email must not be disclosed or copied without the
sender's consent. We cannot accept any resposibility for viruses, so please
scan all attachments.
The statements and opinions expressed in this message are those of the
author and and do not necessarily reflect those of the company. The company
does not take any responsibility for the views of the author.
_______________________________________________
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.