Re: Accessing instance variables: Xcode warnings

Ben Kennedy

On 11 Dec 2020, at 11:02 am, Carl Hoefs <> wrote:

Q1: "Direct" access to an instance variable bypasses its setter/getter methods, but otherwise what is wrong with it?
I haven't seen this warning myself (at least recently), but presumably it is intended to draw attention to the fact that you might be unintentionally avoiding the property accessors.

Q2: Sometimes using the underscore form, _mType, quiets the direct access warning; other times Xcode acts like it doesn't know what I'm referring to. What is the underscore intended for?
Do you have a `@synthesize` directive in the implementation? I believe that by default, `@synthesize` with no arguments will create backing store with the same name as the property. Typically, when the backing store is automatically created, it gets named with the underscore prefix. (You can achieve the same thing manually with `@synthesize mType=_mType;`.)


Join to automatically receive all group messages.