Re: NSInvocation and ints
Re: NSInvocation and ints
- Subject: Re: NSInvocation and ints
- From: Sherm Pendley <email@hidden>
- Date: Fri, 18 Apr 2003 22:57:41 -0400
On Friday, April 18, 2003, at 09:46 PM, Francisco Tolmasky wrote:
I'm trying to use NSInvocation to send a message with a selector that
takes an int as an argument. How do I do this? I tried both of these
and they seemed to not work:
[invocation setArgument: 1 atIndex: 3];
and
int a= 1;
[invocation setArgument: &a atIndex: 3];
Your second example is correct - you need to pass the address of a
variable that holds the argument value, not the value itself.
Having said that, two potential problems come to mind:
First, you need to take into account the two hidden arguments, self and
_cmd. It looks as if you are, however, as you mention only a single
explicit argument, an int, and you're passing it at index 3. Which leads
to the second potential problem...
The index parameter is zero based. The two hidden arguments are at
indices 0 and 1. For a selector that takes a single argument, that
argument is at index 2 - not 3, as in your examples.
sherm--
Thus spake the master programmer:
"When the program is being tested, it is too late to make design
changes."
-- The Tao of Programming
_______________________________________________
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.