> On Feb 18, 2015, at 5:34 PM, Greg Parker <[email protected]> wrote:
>
> There's no such thing as an optional property nor a class property in a
> protocol. All properties in a protocol are required instance properties.
Wait, what? I’ve used optional properties in protocols before; and just to make
sure, I wrote a little example:
@protocol YYY
@property int req;
@optional
@property int opt;
@end
@interface ZZZ : NSObject <YYY>
@end
@implementation ZZZ
@synthesize req;
@end
@interface ZZZBad : NSObject <YYY>
@end
@implementation ZZZBad
@end
Compiling this in Xcode 6.3beta, with auto property synthesis turned off,
produces:
test.m:55:17: error: auto property synthesis will not synthesize property 'req'
declared in protocol 'YYY' [-Werror,-Wobjc-protocol-property-synthesis]
@implementation ZZZBad
^
test.m:40:15: note: property declared here
@property int req;
^
1 error generated.
In other words, class ZZZ compiles because the missing property ‘opt’ is
declared optional; but class ZZZBad fails because it doesn’t implement the
required property ‘req’.
—Jens _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com
This email sent to [email protected]