Sign up for FlowVella
Sign up with FacebookAlready have an account? Sign in now
By registering you are agreeing to our
Terms of Service
Loading Flow
Properties may have getters and setters
Properties may be calculated
Objects: Properties
protocol Exercising {
var heartRateIncrement : Int { get set }
func describe() -> String
}
class Sprint : Exercising {
var isWindSprint : Bool {
get {
return heartRateIncrement > 40
}
}
init() {
heartRateIncrement = 30
}
var heartRateIncrement : Int {
willSet (newIncrementor) {
println("About to set incrementor to \(newIncrementor)")
}
didSet {
println("Set incrementor to \(heartRateIncrement)")
}
}
func describe() -> String {
if isWindSprint {
return "Windsprinting"
} else {
return "Sprinting"
}
}
}
Properties may have observers that monitor when a value is about to, or has just changed