Re: User interface validation doesn't work, right?
Re: User interface validation doesn't work, right?
- Subject: Re: User interface validation doesn't work, right?
- From: Michael Ash <email@hidden>
- Date: Thu, 2 Jul 2009 12:42:07 -0400
On Thu, Jul 2, 2009 at 3:48 AM, Bill Cheeseman<email@hidden> wrote:
> I did find it confusing when I read the NSMenuItem and NSToolbarItem Class
> Reference documents, which say that they conform to the other protocol, the
> NSValidatedUserInterface protocol. But this tends to suggest that NSButton
> will work, too, since NSControl, from which NSButton inherits, also conforms
> to the NSValidatedUserInterface protocol. It doesn't say so, but Apple's
> documentation has a long history of neglecting to mention all the protocols
> that a class conforms to. I was able to confirm from the NSControl Class
> Reference document, and you can too, that NSControl does implement the
> -action and -tag methods required by the NSValidatedUserInterface protocol.
> So, again, I don't understand why you say it doesn't.
Because it doesn't.
You seem to think that protocol conformance is simply a matter of
having declared the proper methods. That's not how it works. If you
check with -conformsToProtocol:, it will return NO. If you try to
assign to a pointer of type id <NSValidatedUserInterface> the compiler
will warn you.
Protocol conformance is a matter of having the declaration in the
header. Nothing else counts. Especially here, where the protocol is
obviously being used as a way to claim a particular behavior, not just
an ability to respond to certain selectors.
As proof, I submit NSObject and NSCopying. NSCopying contains a single
method, -copyWithZone:. NSObject implements this method. And yet,
NSObject does not conform to NSCopying, and if you try to copy one it
will fail.
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