Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning when omitting / removing 'strong' attribute from Property?

Reading ProgrammingWithObjectiveC, I can say:

There’s no need to specify the strong attribute explicitly, because it is the default.

If I omit the 'strong' attribute for a property in my project like this,

@property (nonatomic) NSString *string;

it gives me a warning:

No 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed

aka.

-Wobjc-property-no-attribute

So somehow the compiler seems to be thinking that I´m still doing manual reference counting, otherwise there wouldn´t be any warning.

Also, when creating a new empty project, it doesn´t warn me when there´s no 'strong' attribute, so it must have something to do with the current project settings, maybe even some flag that isn´t reachable via the UI. The project is a rather old one (~2 years) and has undergone several migration steps in the meantime (XCode 3 > 4 > 5, Non-ARC > ARC etc.).

I´ve looked everywhere in the project settings, but somewhere seems to be a missing checkmark or something.

Anyone experiencing the same problem?

like image 284
stk Avatar asked Mar 24 '14 15:03

stk


2 Answers

Just searched for it, and the closest build property would be CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES which I doubt has any relationship.

You can check which default parameters your target overrides by selecting "All" and "Levels" options in the Build Settings view.

enter image description here

Check for the warnings that default to No but are being turned into Yes by your target.

like image 148
Rivera Avatar answered Nov 10 '22 22:11

Rivera


Make sure you have the latest version of Xcode. This is a new compiler feature and how it works has changed several times in recent updates.

Make sure your project is configured to use clang/llvm and not gcc. I can't remember if gcc supports ARC at all (can someone comment of they do know?) but it definitely doesn't support all the features. And an old Xcode project will be using gcc unless you changed it. All recent language changes are only implemented in clang/llvm

Do you have ARC enabled? That will change the behaviour as we'll beware ARC can be enabled or disabled project wide or for specific files.

Some changes in Xcode only apply to new projects, and old projects have are configured to disable them. Have a look over the settings for anything related to ARC that is not set to the default value.

like image 31
Abhi Beckert Avatar answered Nov 10 '22 21:11

Abhi Beckert