RE: Private ivars, not marked as IBOutlet, visible in IB
RE: Private ivars, not marked as IBOutlet, visible in IB
- Subject: RE: Private ivars, not marked as IBOutlet, visible in IB
- From: Jeff Laing <email@hidden>
- Date: Mon, 15 Mar 2010 22:49:20 +0000
- Acceptlanguage: en-US
- Thread-topic: Private ivars, not marked as IBOutlet, visible in IB
> > I could be wrong on this, but I definitely recall thinking it was a
> stupid compiler behavior.
>
> This is because you didn't declare your protocol as extending the
> NSObject protocol. If you do something like this:
>
> @protocol MyProtocol<NSObject>
>
> Then you can call all the NSObject stuff without warning.
But my protocol only wanted to define the methods in my protocol - a nice clean Interface definition that's independent of all other definitions. After all, Apple might add some non-optional methods to NSObject (ok, that's unlikely) that all objects implementing my protocol would suddenly fail to compile on.
Objects could implement MyProtocol *without* implementing NSObject and still be completely useful functionality. They just couldn't be used by code that has chosen to do *other* things to them as well.
To keep the discussion from descending into the foolishly abstract, consider NSCopying as the protocol instead. If I want to let you know that the delegate will be stored in a dictionary, I would define the delegate as id<MyProtocol,NSObject,NSCopying>. Would you seriously think it was a good style to declare @protocol MyProtocol<NSObject,NSCopying> ?
In my opinion, this is a case where interface definitions are being specified badly to get around an implementation problem.
Sure, the delegate they pass in will *probably* be a subclass of NSObject but its not a given, as far as the compiler is concerned. If it must be, then declare it properly.
I don't think people understand that id<NSObject,MyProtocol> specifies a hell of a lot less than NSObject<MyProtocol> - all the categories on class NSObject for a start.
_______________________________________________
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
References: | |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Lynn Barton <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Joanna Carter <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Thomas Engelmeier <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Joanna Carter <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Alexander Spohr <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Roland King <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Joanna Carter <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Alexander Spohr <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: Kevin Cathey <email@hidden>) |
| >RE: Private ivars, not marked as IBOutlet, visible in IB (From: Jeff Laing <email@hidden>) |
| >Re: Private ivars, not marked as IBOutlet, visible in IB (From: David Duncan <email@hidden>) |