Allow property observers to be declared in extensions
| Originator: | DeFrenZ | ||
| Number: | rdar://22855646 | Date Originated: | 25-Sep-2015 02:35 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Swift 2.0 |
| Classification: | Enhancement | Reproducible: | Not Applicable |
Summary:
It would be really useful for code localisation to allow for property observers (willSet, didSet) to be applied in extensions and even more than once (without any specific restriction on the order they will be ran in).
e.g.
class Foo {
private var foo: Int = 0
private var count: Int = 0
}
//MARK: notifier
extension Foo {
overload var foo: Int {
didSet { print(“foo is now \(foo)”) }
}
}
//MARK: counter
extension Foo {
overload var foo: Int {
didSet { count++ }
}
}
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!