Objective-C Property Attribute Attributes

After several searches and reading of the attributes of properties, I still cannot fully understand them and create a reflex for their proper use.

I have a few questions:

1) What is an attribute default?

As I understand it, without specifying an attribute in the "group", it is used by default, so this is:

@property NSString *string;

yes atomic, right?

By this logic , this article says that strongand assignare the default values, so if I have:

@property (nonatomic) NSString *string;

Is this a property string strongor assign?

How are available attributes β€œgrouped”? Or how does Xcode words mean, which attributes are mutually exclusive?

2) Are there any general rules that should be followed?

, , , copy , NSString, NSArray.

, , assign C.

, :

@property (copy, nonatomic) NSString *string;
@property (assign, nonatomic) CGFloat float;

?

?

3) , "" ? , nonatomic ?

+4
1

1a) atomic strong ( ) assign ( ) readwrite. ARC.

, @property NSString *string; @property (atomic, strong, readwrite) NSString *string;. @property int value; @property (atomic, assign, readwrite) int value;.

1b) :

  • /
  • ///
  • /

.

, Objective-C nullable/nonnull nullable.

2) , .

  • strong.
  • assign.
  • weak child/parent, . , . weak .
  • copy NSString, NSArray, NSDictionary .., , . .
  • "getcha" copy NSMutableString, NSMutableArray .., , , copy copy, . , setter mutableCopy.

3) .

  • assign strong , , . - .

  • nonatomic atomic , , / .

  • strong copy NSString NSArray ( ) , .

+12

Source: https://habr.com/ru/post/1627271/


All Articles