Re: Creating Interface
Re: Creating Interface
- Subject: Re: Creating Interface
- From: Phil <email@hidden>
- Date: Fri, 29 Aug 2008 01:03:33 +1200
On Fri, Aug 29, 2008 at 12:32 AM, Jean-Daniel Dupas
<email@hidden> wrote:
> When you use the id<protocol> syntaxt, the compiler assume your object only
> implements the method declared in your protocol.
> If you want to use some other function, you have to use an object type that
> declare thoses functions, for example in your case, NSObject.
>
However, NSObject is both a class and a protocol. Although most
classes inherit from NSObject, this is not always the case (for
example, using DO, where objects inherit from the NSProxy root class).
It's preferrable if your protocol incorporates the NSObject protocol
as well, which enforces all implementors to also conform to the
NSObject protocol (and you take an id<MyProtocol>)---because you don't
actually care if you have an NSObject subclass, just that whatever
you've got behaves like an NSObject.
Phil
_______________________________________________
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