Search code examples
iosobjective-cmemory-managementdeclared-property

Is declaring strong actually needed for Objective-C properties?


My understanding so far is that (retain) increases the reference count of a property and is essentially the exact same as (strong). Since all properties are set to retain by default (unless specified otherwise), is adding (strong) needed at all:

@property(nonatomic, strong) NSString *name;

Is the same as:

@property(nonatomic) NSString *name;

Both the above are the same, right?


Solution

  • Since ARC was introduced, "strong", "atomic", and "readwrite" are set by default.

    These properties are equivalent:

    @property NSArray *name;
    @property (strong, atomic, readwrite) NSArray *name;
    

    Source: http://useyourloaf.com/blog/default-property-attributes-with-arc.html