@property assign

If I "set" the default value, can I leave it empty and it will force it to be assigned?

@property BOOL sample;

What if I determined its atomicity and then left it empty?

@property (nonatomic) BOOL sample;
+3
source share
2 answers

Yes, default values ​​are used unless otherwise specified. However, good practice should be explicit in property definitions. It is easier for a third party to understand what is happening and / or to know what is going to happen. In addition, implementation details may change in the future.

+6
source

Yes you are right:

@property BOOL sample;

is equivalent to:

@property (atomic, assign) BOOL sample;

But, of course, atomic is not an attribute that exists, so do not use it :)

+3
source

All Articles