Re: Accessing instance variables: Xcode warnings

James Walker

On Dec 14, 2020, at 4:08 PM, Jens Alfke <> wrote:

On Dec 11, 2020, at 12:33 PM, Alex Zavatone via <> wrote:

_mType is the internal class scoped copy of it.

self. is safest. It’s wrapped with the get and set accessors.
It's not that much safer, really. There's no difference in single-threaded code. If the property is being read and written on multiple threads, and you declare the property @atomic, the getter and setter will be thread-safe while the direct read/write can in some cases crash. (But only if it's an object pointer, not a scalar.)

In most cases, inside the class implementation I [used to] just access the ivar directly because it's a lot faster and produces smaller code.

Setting the instance variable directly will not be reported to KVO observers. Sometimes that may be what you want, other times not.

Join to automatically receive all group messages.