Re: NSInvocation driving me nuts
Re: NSInvocation driving me nuts
- Subject: Re: NSInvocation driving me nuts
- From: "Pontus Ilbring" <email@hidden>
- Date: Sat, 8 Apr 2006 14:02:36 +0200
On 4/8/06, Pierre Bernard <email@hidden> wrote:
> Can you spot the difference between:
>
> [delegate _managedObjectContextEditor:self
> didCommit:YES
> contextInfo:contextInfo];
>
> and this:
>
> SEL selector = @selector
> (_managedObjectContextEditor:didCommit:contextInfo:);
> NSInvocation *invocation = [NSInvocation
> invocationWithMethodSignature:[delegate
> methodSignatureForSelector:selector]];
> BOOL success = YES;
>
> [invocation setTarget:delegate]; // 0
> [invocation setSelector:selector]; // 1
> [invocation setArgument:&self atIndex:2];
> [invocation setArgument:&success atIndex:3];
> [invocation setArgument:&contextInfo atIndex:4];
> [invocation retainArguments];
> [invocation invoke];
>
> [invocation release];
>
> Well, the first one works. The second does not!
You never retain your invocation -- only its arguments, and then you
call release on it.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden