Re: Newbie Question re: callback signatures
Re: Newbie Question re: callback signatures
- Subject: Re: Newbie Question re: callback signatures
- From: Quincey Morris <email@hidden>
- Date: Fri, 4 Jun 2010 13:33:46 -0700
On Jun 4, 2010, at 13:03, Brad Stone wrote:
> How do I create the callback method? I don't understand what the signature is telling me. I have canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: in my NSDocument and I want to set up the callback method. When I create a method as below it never fires. I must just not be reading it correctly.
>
> - (void)document:(NSDocument *)doc shouldClose:(BOOL)shouldClose contextInfo:(void *)contextInfo {
> NSLog(@"hey, it finally worked!");
> }
>
> What exactly should the method be in my NSDocument?
It's a bit confusing, because your 'canCloseDocumentWithDelegate...' is an override. That means a delegate selector is being passed *in* to this method, and it's not your selector. There's no direct way to substitute your 'document:shouldClose:...' method for the supplied one.
But there is a solution. Look in the Leopard AppKit Developer Release Note:
http://developer.apple.com/mac/library/releasenotes/Cocoa/AppKitOlderNotes.html
in the section with the following title:
Advice for Overriders of Methods that Follow the delegate:didSomethingSelector:contextInfo: Pattern
This explains what you need to do to get your method to be called.
_______________________________________________
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