Re: Accessing instance variables: Xcode warnings


 



On Dec 11, 2020, at 12:33 PM, Alex Zavatone via groups.io <zav@...> 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.

—Jens

Join xcode@apple-dev.groups.io to automatically receive all group messages.