• 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: Typing class parameters.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Typing class parameters.


  • Subject: Re: Typing class parameters.
  • From: Brendan Younger <email@hidden>
  • Date: Sat, 08 Jan 2005 14:02:51 -0600


On Jan 8, 2005, at 1:47 PM, Tommy Nordgren wrote:

The initializer for a custom view I've written takes a parameter of type "class". Is there any way to declare that it should be limited to classes that either:
a) Is derived from a specific base class, or
b) Implements a specific protocol.

You should check either instancesRespondToSelector: or conformsToProtocol: in the initialization method (don't check for inheritance, it's unnecessarily constricting), and throw an exception if the class doesn't respond to what you need of it. You shouldn't make it a requirement in the declaration since: it's constricting and it doesn't guarantee that the parameter will really be correct.


Brendan Younger

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Typing class parameters. (From: Tommy Nordgren <email@hidden>)

  • Prev by Date: Typing class parameters.
  • Next by Date: Re: Variadic arguments to methods in Objective-C - How ?
  • Previous by thread: Typing class parameters.
  • Next by thread: How to disable NSTextView's HTML rendering?
  • Index(es):
    • Date
    • Thread