Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS readonly and retain are mutually exclusive

Tags:

objective-c

I want to have a strong readonly property. When I use this code:

@property (strong, nonatomic, readonly) NSString *test;

I get a warning: "Property attributes 'readonly' and 'retain' are mutually exclusive". How can I solve this warning?

like image 479
Haagenti Avatar asked Jan 23 '26 14:01

Haagenti


1 Answers

Create a property in your continuation category which redefines the variable as readwrite:

@property (strong, nonatomic, readwrite) NSString *test;

Now, publicly the property is read only, but privately you can write it. The compiler will generate the methods you need and allow you to call them.

like image 106
Wain Avatar answered Jan 25 '26 12:01

Wain