• 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
Optional methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optional methods


  • Subject: Optional methods
  • From: "Mike R. Manzano" <email@hidden>
  • Date: Thu, 21 Feb 2008 07:57:44 -0800

Hello,

I'd like to create an informal protocol where objects can have an optional method. Senders of the object would be required to send respondsToSelector: to find out if am object implements the method before calling it.

The problem is that the compiler complains that the method doesn't exist if a sender actually does send that message to an object.

I know about the pattern to shut the compiler up: create a category on NSObject with the method defined, but if I were to do that, wouldn't respondsToSelector: always return YES for that method, defeating the point of calling respondsToSelector: in the first place?

Thanks,

Mike
_______________________________________________

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


  • Follow-Ups:
    • Re: Optional methods
      • From: Keith Duncan <email@hidden>
    • Re: Optional methods
      • From: "Kyle Sluder" <email@hidden>
    • Re: Optional methods
      • From: Quincey Morris <email@hidden>
    • Re: Optional methods
      • From: "Hamish Allan" <email@hidden>
  • Prev by Date: Re: *** -[NSCFDictionary setObject:forKey:]: mutating method sent to immutable object
  • Next by Date: Re: Optional methods
  • Previous by thread: Re: Garbage collection performance
  • Next by thread: Re: Optional methods
  • Index(es):
    • Date
    • Thread