How to write better Swift


Gerriet M. Denkmann
 

This works (Xcode Version 8.3.2 (8E2002)):

class SomeClass
{
private var privateStatus: Int

var status: Int
{
get{ return privateStatus }
set(new)
{
if new == privateStatus {return}

… do something here …

privateStatus = new
}
}
}

But is this “privateStatus” really necessary?
If not, how can it be avoided?

Gerriet.

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