Use weak readonly property?

If you use

@property (nonatomic, weak, readonly)

or

@property (nonatomic, readonly)?

The weak advantage is that it issues an instance if it is freed, but it makes sense to read only the weak? Should one explicit declaration of a property be weak if it wants weak behavior?

+5
source share
2 answers

If you want to keep a pointer to an object that you don’t have, but want it to be valid only as long as it exists, you want to use a weak pointer, because when it is freed by the owner, your pointer will automatically be set to zero and does not indicate the memory that it should not be.


Both of them are differnect, readonly makes no difference if it is weak or strong.

@property (nonatomic, weak, readonly)
@property (nonatomic, readonly)

.

+5

readonly readwrite. .

. , .

Readonly (afaik). . Readwrite ( , ) .

. , . .

+2

All Articles