Skip to content

Instantly share code, notes, and snippets.

@jessedc
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessedc/9224416 to your computer and use it in GitHub Desktop.
Save jessedc/9224416 to your computer and use it in GitHub Desktop.
Demonstrates the stricter behaviour of Xcode 5.1 in regards to overloading objective C property declarations in subclasses. -Wobjc-property-synthesis
#import <UIKit/UIKit.h>
@interface REABaseViewController : UIViewController
@property (nonatomic, readonly, strong) NSObject *anObject;
@end
@interface REAViewController : REABaseViewController
//error: auto property synthesis will not synthesize property 'anObject'
//because it is 'readwrite' but it will be synthesized 'readonly' via
//another property [-Werror,-Wobjc-property-synthesis]
@property (nonatomic, readwrite, strong) NSObject *anObject;
@end
@jessedc
Copy link
Author

jessedc commented Feb 26, 2014

This code snippet compiles without warning in Xcode 5.0.2.

I've asked a question on the apple dev forums. https://devforums.apple.com/thread/220481

@sgleadow
Copy link

that makes sense to me... I think

@tonyarnold
Copy link

I'm not sure this ever should have worked… it sounds like an invitation to all kinds of craziness. Redefining readonly/readwrite in a class extension within the same .h/.m has always worked, but beyond that you're just setting yourself up for undefined behaviour?

@AncAinu
Copy link

AncAinu commented Mar 13, 2014

This grind my gears too, I was using it often

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment