他们之间有什么区别?你能举个例子说明我应该使用dynamic/mutable/any/constants属性吗?
你的所有答案都在这个链接Property.swift
我举几个例子:
let privatString = MutableProperty("PrivatString") // AnyProperty are only for observing. You can't change it with observableProperty.value let observableProperty: AnyProperty = AnyProperty (privatString) print(observableProperty) // ConstantProperty describes observable constant value. let constantProperty = ConstantProperty ("ConstantString") // constantProperty.value = "" Error // Thread safe observable mutable property. It's value is changable let mutableProperty = MutableProperty ("mutableProperty") mutableProperty.value = "New mutable property value" // DynamicProperty uses KVO. let dynamicProperty = DynamicProperty(object: self.view.layer, keyPath: "bounds") dynamicProperty.producer.startWithNext { frame in let frame = frame as! NSValue let rect = frame.CGRectValue() print(rect) }