NSInvocation and methods with non-pointer parameters
NSInvocation and methods with non-pointer parameters
- Subject: NSInvocation and methods with non-pointer parameters
- From: Jim Kang <email@hidden>
- Date: Mon, 2 Nov 2009 05:17:34 -0500
I seem to be able to use NSInvocation to execute methods that have
parameters are pointers, like NSString* or NSDictionary*, but when I try to
invoke a method with a parameter that is not a point, like this -
(void)methodWithCGPoint: (CGPoint)pos;
- I get an EXC_BAD_ACCESS when I run it with code like this:
SEL sel = @selector(methodWithCGPoint:);
if ([self respondsToSelector: sel])
{
NSMethodSignature *sig = nil;
sig = [[self class] instanceMethodSignatureForSelector:sel];
NSInvocation *invocation = nil;
invocation = [NSInvocation
invocationWithMethodSignature:sig];
[invocation setTarget:self];
[invocation setSelector:sel];
[invocation setArgument:&pos atIndex:2];
[invocation invoke];
}
What is the correct way to set the CGPoint argument to NSInvocation? The
CGPoint can't get released before the invocation is finished, so [invocation
retain] doesn't help.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden