• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSInvocation and methods with non-pointer parameters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSInvocation and methods with non-pointer parameters
      • From: Bill Bumgarner <email@hidden>
    • Re: NSInvocation and methods with non-pointer parameters
      • From: Dave Keck <email@hidden>
  • Prev by Date: Unable to open Core Data documents
  • Next by Date: Handling projects with several XIBs
  • Previous by thread: re: Unable to open Core Data documents
  • Next by thread: Re: NSInvocation and methods with non-pointer parameters
  • Index(es):
    • Date
    • Thread