Warning thrown for direct variable access in getter and setter methods

Originator:danielctull
Number:rdar://13202120 Date Originated:
Status: Resolved:
Product:Developer Tools Product Version:Xcode 4.6
Classification:Enhancement Reproducible:Always
 
Summary:
The warning -Wdirect-ivar-access is giving for ivars accessed in their getter and setter methods.

Steps to Reproduce:

Declare properties as such:

@property (nonatomic, strong) id object;
@property (nonatomic, strong) id anotherObject;

and then write a custom accessor or setter method:

- (id)object {
	return _object;
}

- (void)setAnotherObject:(id)anotherObject {
	_anotherObject = anotherObject;
}

Expected Results:
No warnings thrown for accessing the respective ivar for the property you are getting or setting.

Actual Results:
-Wdirect-ivar-access is thrown.

Comments


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!