On Nov 2, 2009, at 2:17 AM, Jim Kang wrote:

> 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.

If you are targeting Snow Leopard, use blocks instead... much more 
straightforward.

b.bum
_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to