• 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
Re: Newbie Question re: callback signatures
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Newbie Question re: callback signatures (From: Brad Stone <email@hidden>)

  • Prev by Date: Re: Class OC_PythonObject: no such selector: _cfTypeID
  • Next by Date: Re: va_list and unanticipated format specifiers
  • Previous by thread: Newbie Question re: callback signatures
  • Next by thread: Forcing IKImageBrowserView to center its cells?
  • Index(es):
    • Date
    • Thread