RE: Method selectors and parameter passing
RE: Method selectors and parameter passing
- Subject: RE: Method selectors and parameter passing
- From: Oliver Donald <email@hidden>
- Date: Tue, 10 Dec 2002 13:28:30 -0000
>
The simplest way to deal with this is to make sure each method has the
>
same signature, while allowing for multiple parameters. To do that :
>
wrap up the parameters themselves in some sort of collection: either
>
an NSArray or an NSDictionary - an NSArray would allow you complete
>
freedom in terms of what you pass in, and an NSDictionary would allow
>
you more control over the types being passed in.
>
>
If we assume that your 'genome' returns a pipeline, and that we're
>
working on NSImages, and that the selectors will be added as a category
>
on NSImage, and we want to use named parameters, the signature for each
>
selector might look something like this:
>
>
NSImage * theImage = .....;
>
id enumerator = [genome objectEnumerator];
>
id gene;
>
>
while (gene = [enumerator nextObject]) {
>
SEL selector = [gene objectAtIndex:0];
>
id params = [gene objectAtIndex:0];
>
theImage = [theImage performSelector:selector withObject:params];
>
}
thanks, that looks to be what I need. I had a look at invocations but
unfortunately they don't support varying numbers of parameters according to
the docs. One question about the above though, should
id params = [gene objectAtIndex:0];
...be...
id params = [gene objectAtIndex:1]; ???
thanks to everyone for the help!
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.