Re: A question about IMP
Re: A question about IMP
- Subject: Re: A question about IMP
- From: "David W. Halliday" <email@hidden>
- Date: Fri, 14 Feb 2003 16:34:17 -0600
- Organization: TNRCC
Roman Fischer wrote:
I know I can use the IMP to call directly a methods code, eg:
SEL s = @selector(myMethod);
IMP i = [myObject methodForSelector:s];
i(anObject,anSelector);
I understand that the function call needs an object it reference to (eg. for
a link to the instance variables of an object).
It's also "self" variable/argument (basically, that's the
argument/parameter name of the fist argument/parameter).
But why does the function call need a selector? I would think that the IMP
IS the reference without the need of a Selector again. Even if I put nil
into the place of "anSelector" it seems to me to work without any problems.
Can anybody explain the reason for that parameter to me?
The name of the second parameter is "_cmd". It can be used by the
method for debug purposes, message forwarding, or any of a number of
other things. If, in your example, you don't set the second parameter
to "s", then you may get some very interesting behavior, if the method
uses this parameter for something. (Since most methods don't use this
parameter, this is not an issue, though this parameter may be used if an
exception is thrown.)
Thank You
Roman
David At Halliday Dot name
_______________________________________________
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.