I have an Objective-c class "MyClass". In MyClass.m I have a class extension that declares a CGFloat property:
@interface MyClass () @property (nonatomic) CGFloat myFloat; @end @implementation MyClass @synthesize myFloat; //... @end
What changes (if any) when a property is declared using the readonly keyword?
@interface MyClass () @property (nonatomic, readonly) CGFloat myFloat; @end @implementation MyClass @synthesize myFloat; //... @end
Perhaps in the first case, I can say self.myFloat = 123.0; and CGFloat f = self.myFloat; inside MyClass? Then, in the second case, the readonly keyword prevents self.myFloat = 123.0; but allows you to read CGFloat f = self.myFloat;
source share