@property defaulting to strong is poorly documented

Number:rdar://11071507 Date Originated:
Status:Marked As Duplicate Resolved:
Product: Product Version:
Classification:Serious Bug Reproducible:N/A
18-Mar-2012 10:09 PM Doug Russell:

As of Xcode 4.3 @property defaults to strong for objects.

This is made clear by: 

the arc migration tool

direct testing

other developer experience - https://devforums.apple.com/message/620858

LLVM commit messages - http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransProperties.cpp?revision=142304&view=markup

I would expect that this would be documented in: 

the ARC docs - http://clang.llvm.org/docs/AutomaticReferenceCounting.html#ownership.spelling.property

or the docs for properties - https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProperties.html#//apple_ref/doc/uid/TP30001163-CH17

but it is not.

Steps to Reproduce: 

Use ARC and don't declare any ownership qualifier on an object type property

Expected Results: 

Warning about lack of ownership qualifier or default to assign (the old default)

Actual Results:

Strong property


Xcode 4.2.x did not default to strong for object properties when using ARC



Also in Clang ARC Reference

The link now leads to a section that includes:

A property of retainable object pointer type which is synthesized without a source of ownership has the ownership of its associated instance variable, if it already exists; otherwise, [beginning Apple 3.1, LLVM 3.1] its ownership is implicitly strong. Prior to this revision, it was ill-formed to synthesize such a property.

Rationale Using strong by default is safe and consistent with the generic ARC rule about inferring ownership. It is, unfortunately, inconsistent with the non-ARC rule which states that such properties are implicitly assign. However, that rule is clearly untenable in ARC, since it leads to default-unsafe code. The main merit to banning the properties is to avoid confusion with non-ARC practice, which did not ultimately strike us as sufficient to justify requiring extra syntax and (more importantly) forcing novices to understand ownership rules just to declare a property when the default is so reasonable. Changing the rule away from non-ARC practice was acceptable because we had conservatively banned the synthesis in order to give ourselves exactly this leeway.

By jeremyw.sherman at Jan. 10, 2013, 8:24 a.m. (reply...)

I knew I'd read this in some Apple doc

It's documented in the Transitioning to ARC Release Notes. There's a section on properties that concludes with, “Under ARC, strong is the default for object types.” Not exactly the first place you'd look, eh?

By jeremyw.sherman at Jan. 10, 2013, 8:20 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!