• 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: Cocoa's custom class delegate conventions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa's custom class delegate conventions


  • Subject: Re: Cocoa's custom class delegate conventions
  • From: Jean-Francois Roy <email@hidden>
  • Date: Sat, 14 Jun 2003 01:00:36 -0400

My questioning is really about the sending of delegate selectors more than checking if a delegate implements a given method? Should I send on the main thread or not?

On Saturday, Jun 14, 2003, at 00:58 America/Montreal, Sherm Pendley wrote:

On Friday, June 13, 2003, at 11:46 PM, Marco Scheurer wrote:

First you should at least verify that your delegate does respond to the selector (respondsToSelector:) you will invoke.

if ((delegate != nil) && ([delegate respondsToSelector:@selector(thingWillDoStuff:)) {
[delegate performSelector:@selector(thingWillDoStuff:) withObject:self];
}

If there are methods that the delegate *must* implement, then you can declare those methods as part of a formal protocol. You can then declare the iVar that refers to the delegate as id<MyDelegateProtocol>, and call the delegate methods directly, without having to route them through performSelector:. A protocol would also allow you to simply send the would-be delegate a single conformsToProtocol: message in setDelegate: instead of a series of respondsToSelector: messages scattered about your code.

sherm--

The wise programmer is told about Tao and follows it. The average programmer is told about Tao and searches for it. The foolish programmer is told about Tao and laughs at it.

If it were not for laughter, there would be no Tao.

-- The Tao of Programming



Jeff Roy

--
Co-Founder of MacStorm
Programmer at MacStorm

http://www.macstorm.org
http://www.theworldcrafters.com
email@hidden
_______________________________________________
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: Cocoa's custom class delegate conventions
      • From: Dustin Voss <email@hidden>
References: 
 >Re: Cocoa's custom class delegate conventions (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: Cocoa's custom class delegate conventions
  • Next by Date: Re: NSApplication delegate not released on quit?
  • Previous by thread: Re: Cocoa's custom class delegate conventions
  • Next by thread: Re: Cocoa's custom class delegate conventions
  • Index(es):
    • Date
    • Thread