When a lot of XXX.h file attributes yy design, the external design is yy (readonly), the outside world can not modify the property,
At the same time, the problem also came, the XXX class can not modify the internal changes to YY properties, you have an instant messy ... Y_y
Then we found the following two ways:
One: pointer
Never underestimate the power of the pointer, in the internal can be modified by the obj->_yy of the YY property, this way is also true
It's a little bit yy.
Instantly turn red with wood//self . Yyname = @ "skyming"; Self->_yyname = @ "skyming";
Two: Re-declaring attributes
Seemingly very formal appearance, if you write the class attributes are not many, the company does not have any other code specifications, directly placed in
Re-declare it again in. M.
Let's compare the statement in H.
@interface Xxx:nsobject@property (nonatomic, ReadOnly, strong) NSString *yyname; @end
The declaration in. M @interface XXX () @property (nonatomic, ReadWrite, strong) NSString *yyname; @end
If you have readonly in the same property,. h files,. m files, you will get an error.
Of course, if the attribute is more, or in the SDK, then directly write a private. h Bar
And that's how it's done in many of the company's internal SDKs 、、、
If your company's SDK is like this, you silently praise it, y_y
A little bad idea of IOS for ReadOnly