This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct TemperatureLimits { | |
var low: Int = 5 { | |
didSet { | |
let high = max(self.high, low + 10) | |
guard self.high != high else { return } | |
self.high = high | |
} | |
} | |
var high: Int = 30 { | |
didSet { | |
let low = min(self.low, high - 10) | |
guard self.low != low else { return } | |
self.low = low | |
} | |
} | |
var lowNumber: NSNumber { | |
get { NSNumber(value: low) } | |
set { low = newValue.intValue } | |
} | |
var highNumber: NSNumber { | |
get { NSNumber(value: high) } | |
set { high = newValue.intValue } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment