Re: [swift-users] How to write better Swift

2017-07-10 Thread Gerriet M. Denkmann via swift-users
> On 10 Jul 2017, at 22:35, Geordie J via swift-users > wrote: > > Would “didSet" on a normal variable work for you? willSet/didSet usually is a good solution (which I had forgotten about). But in my case it seems not to help - see the corrected code below > var status: Int { > didSet { doS

Re: [swift-users] How to write better Swift

2017-07-10 Thread Adrian Zubarev via swift-users
It should be willSet because in the example the job is executed before the new value is set. class SomeClass { var status: Int { willSet { guard newValue != self.status { return } // do something here } } } --  Adrian Zubarev Sent with Airmail A

Re: [swift-users] How to write better Swift

2017-07-10 Thread Geordie J via swift-users
Would "didSet" on a normal variable work for you? var status: Int { didSet { doSomething() } } Geordie > Am 10.07.2017 um 17:34 schrieb Gerriet M. Denkmann via swift-users > : > > This works (Xcode Version 8.3.2 (8E2002)): > > class SomeClass > { > private var privateStatus: Int >

[swift-users] How to write better Swift

2017-07-10 Thread Gerriet M. Denkmann via swift-users
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}