• 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: OBJ-C question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OBJ-C question


  • Subject: Re: OBJ-C question
  • From: Kay Roepke <email@hidden>
  • Date: Sat, 17 Apr 2004 19:55:41 +0200

On 17. Apr 2004, at 19:37 Uhr, Sherm Pendley wrote:

There's also efficiency to consider - without a default implementation, you have to call respondsToSelector: before each call to a data source method. You couldn't simply call it in setDataSource: because the method could be added to the class after the data source object has been assigned. Not only would this clutter up your code, it would introduce a bottleneck in what is usually a frequently-called time-critical method.

A pattern I've seen quite often in Apple's headers (I think it was in Xcode class-dumps. Not too sure anymore where it was...) is
to have a struct in which the result of respondsToSelector: (i.e. YES/NO) is saved.

This way you do not have the overhead of a method dispatch like you do if you have a dummy method somewhere in your ancestry.
You would check for the supported methods in your setDelegate: method and whenever you want to call the delegate methods have a check
if it's ok to send the message.

Kay
_______________________________________________
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: OBJ-C question
      • From: Sherm Pendley <email@hidden>
    • Re: OBJ-C question
      • From: Ondra Cada <email@hidden>
References: 
 >OBJ-C question (From: "Mike R. Manzano" <email@hidden>)
 >Re: OBJ-C question (From: Ondra Cada <email@hidden>)
 >Re: OBJ-C question (From: "Mike R. Manzano" <email@hidden>)
 >Re: OBJ-C question (From: Ondra Cada <email@hidden>)
 >Re: OBJ-C question (From: Sherm Pendley <email@hidden>)
 >Re: OBJ-C question (From: Ondra Cada <email@hidden>)
 >Re: OBJ-C question (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Moving window to a given screen?
  • Next by Date: Re: [OT] Bug Reporter Questions
  • Previous by thread: Re: OBJ-C question
  • Next by thread: Re: OBJ-C question
  • Index(es):
    • Date
    • Thread