Re: Typing class parameters.
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