Created
June 7, 2017 15:44
-
-
Save SlaunchaMan/9e7a6317f9c862e3912bcd0c96704f65 to your computer and use it in GitHub Desktop.
Attempting to use the new block-based KVO in Xcode 9 and Swift 4
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import Foundation | |
class HelloThere: NSObject { | |
@objc var value: String = "" | |
} | |
let object = HelloThere() | |
let observer = object.observe(\.value) { (object, change) in | |
print("Changed to \(object.value)") | |
} | |
object.value = "1" | |
object.value = "2" | |
object.value = "3" | |
print("At end") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This just prints "At end"—none of the KVO notifications actually fire.