BWSnippet

Swift 3 - compute poperties - didSet

Swift 3 - compute poperties - didSet

handling nifty stuff in didSet on properties can clean up your code quite a bit - if done correctly :P

    var sleeping:Bool = false {
        didSet {
            if( sleeping ){
                print(" were sleeping ")
            } else {
                print(" were not sleeping ")
            }
        }
    }

Tags

Swift 3 - compute poperties - didSet