On Wed, Sep 10, 2008 at 2:56 AM, Chris Idou <[EMAIL PROTECTED]> wrote:
> > I have a need to call performSelector:withObject etc, except I need to pass > 3 arguments. The doco to performSelector:withObject:withObject says to "See > NSInvocation", which I have done, but I don't understand how to use it. Can > anyone give me some code which implements performSelector:withObject etc as > example? Okay, let's assume we're sending a -hello: message to an instance "theGreeter", with the string @"World!" as its argument, and a return value of type int. NSMethodSignature *sig = [theGreeter methodSignatureForSelector: @selector(hello:)]; NSInvocation *invoker = [NSInvocation invocationWithMethodSignature: sig]; NSString *arg = @"World!"; int retVal = 0; [invoker setSelector: @selector(hello:)]; [invoker setArgument: &arg atIndex:2]; // self and _cmd are at index 0 and 1 [invoker invokeWithTarget: theGreeter]; [invoker getReturnValue: &retVal]; All the usual caveats apply - typed into mail, untested, etc. sherm-- -- Cocoa programming in Perl: http://camelbones.sourceforge.net _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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]