Re: Creating Interface
Re: Creating Interface
- Subject: Re: Creating Interface
- From: Chris Hanson <email@hidden>
- Date: Thu, 28 Aug 2008 12:30:17 -0700
On Aug 28, 2008, at 7:32 AM, Roland King wrote:
I don't quite understand why protocols like NSKeyValueObserving
aren't formalized and in a .h file somewhere so you could just use
them in the same way you can the NSObject protocol. They're
documented, why not just write the .h file. There's probably a
very good reason for it which has totally escaped me.
Conforming to a protocol is an all-or-nothing affair - you have to
implement *all* of the protocol's methods. The informal protocols
I'm aware of tend to have one or more optional methods.
You can have @optional Protocol methods (is that new, that may be
new, I'm really not sure).
It's new in Objective-C 2.0 in Leopard.
Prior to that, protocols were always all-or-nothing, just as
interfaces are in Java and C#. (Java actually acknowledges deriving
its concept of interfaces from Objective-C protocols; C# is a Java
derivative.) That's why they weren't used for things like delegates
and data sources where only a subset of methods need to be implemented
to be functional.
-- Chris
_______________________________________________
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