Make an iPhone property read-only in iOS objective-c
问题 OK basically I have a class in an iPhone app where I want it to some read only propertys. Meaning that the owning class can read and write the property, but other objects can only read it. I try the "readonly" option when I declare the property, but then my class can't even write it. What use is that? 回答1: If it's not too inconvenient, just use the ivar or "backing" variable in your class to modify the value. Like this: In your .h file: @interface ClassName @property (readonly,nonatomic)