I do not have anything in particular to achieve, but rather I am trying to learn more about class extension.
This is the explanation of class extension directly from apple Categories and extensions:
@interface MyClass : NSObject
@property (retain, readonly) float value;
@end
// Private extension, typically hidden in the main implementation file.
@interface MyClass ()
@property (retain, readwrite) float value;
@end
it does make perfect sense to me, however, supposing I have a MyClass2 extending MyClass:
@interface MyClass2 : MyClass
@property (retain, readwrite) float value;
@end
so I have few questions, which I could easily answer if class extensions weren't involved:
- at runtime, when in MyClass I am doing an assignment self.value=2 or just calling float x=self.value , which setter and getter @property are called ? MyClass or MyClass2 ?
- shouldn't the compiler at least issue a warning about a readonly property being redefined ?
- I know @property are backed by an ivar, so how many ivar are there in the end ? Related to this, calling the same self.value from MyClass2 point of view which ivar would set ?