I discovered a strange behaviour when working with a property, that was inherited as readonly and than redeclared in the inherited class as readwrite
In A.h
@interface A : NSObject
@property (nonatomic, strong, readonly) NSObject * someProperty;
@end
In B.h
@interface B : A
// no matter if here
// @property (nonatomic, strong, readwrite) NSObject * someProperty;
- (void)foo;
@end
In B.m
@interface B()
// no matter if here
@property (nonatomic, strong, readwrite) NSObject * someProperty;
@end
@implementation B
- (void)foo {
NSLog(@"%@", self.someProperty);
// crash here with unrecognized selector setSomeProperty:
self.someProperty = [NSObject new];
}
@end
calling
self.someProperty = [NSObject new];
causes the code to crash on unrecognized selector "setSomeProperty:"
investigation showed, that it looks like the setter did not get synthetized, even when declared as readwrite
Why is this happening? The compiler didnt indicate any warning for this to happen, nor i found anywhere this behaviour documented