• 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
How does Cocoa implement delegate/callback?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How does Cocoa implement delegate/callback?


  • Subject: How does Cocoa implement delegate/callback?
  • From: Bill Cheeseman <email@hidden>
  • Date: Thu, 14 Nov 2002 12:41:29 -0500

There are many Cocoa methods and functions, like NSBeginAlertSheet, that
give the user an option to pass a temporary delegate and a callback
selector. How does Cocoa implement this?

I ask because I would like to provide a similar option to clients of a class
I'm writing. A complicating factor is that the class I'm writing covers a C
API that expects the callback to be a C function. I want my clients to be
able to write their callbacks as Objective-C methods.

I suppose I can implement the C callback as a function in the class I'm
writing and register it with the C API. Then, when my C callback function is
triggered by the C API, I can have it send a message to my client's callback
selector. But how? Telling the delegate to
performSelector:withObject:withObject: won't work because the callback
method I specify has too many parameters. And I can't figure out how to get
NSInvocation to work.

Is this the best approach? If so, I'll keep digging.

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont - http://members.valley.net/croquetvermont
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: How does Cocoa implement delegate/callback?
      • From: Jérôme Laurens <email@hidden>
    • Re: How does Cocoa implement delegate/callback?
      • From: John Hörnkvist <email@hidden>
    • Re: How does Cocoa implement delegate/callback?
      • From: Bill Cheeseman <email@hidden>
    • Re: How does Cocoa implement delegate/callback?
      • From: Chris Hanson <email@hidden>
    • Re: How does Cocoa implement delegate/callback?
      • From: Sherm Pendley <email@hidden>
  • Prev by Date: UndoManager
  • Next by Date: Re: TIFFRepresentation giving me a tiff WITH an alpha
  • Previous by thread: RE: UndoManager
  • Next by thread: Re: How does Cocoa implement delegate/callback?
  • Index(es):
    • Date
    • Thread