0

Under ARC, when declaring a 'strong' property, is it necessary to explicitly declare it strong?

I have seen much code that does so and wondered if I was missing something?

Since strong is the implicit, default behaviour for all properties, are there any cases where the strong attribute should be explicitly mentioned?

  • 3
    The real answer is that since nobody really knows, it's safest to explicitly code `strong` (and good documentation, too). – Hot Licks Mar 18 '14 at 21:04
  • 1
    Being explicit is always good. Writing "strong" means it is "strong" because you intended it to be strong. Writing nothing means it is either strong because you intended it to be strong and knew it is the default, or it is strong because you intended it to be weak and incorrectly guessed the default or plain forgot to write "weak". – gnasher729 Mar 18 '14 at 21:51

1 Answers1

2

The definitive specification is here 4.1.1 Property declarations

That is, for example, the default ownership attribute for a property is strong if the property value is a retainable object, and unless the source doesn't explicitly specify the ownership differently than strong.

It is recommended to explicitly specify the ownership attribute - just to be clear and for documentation.

Depending on the implementation of synthesized properties, an atomic attribute may imply strong ownership. This, and other useful information can be read in the official documentation: Transitioning to ARC Release Notes.

CouchDeveloper
  • 18,174
  • 3
  • 45
  • 67