HI Team,
Its a weird no idea is it a iOS 9.3 SDK is broken or is it a bug..
Im trying a KVO on NSUserDefaults in swift and im getting that "observeValueForKeyPath" has been called multime times..
Check my below code
Global Variable:
private var myContext = 0
1. ViewWill appear ()
NSUserDefaults.standardUserDefaults().addObserver(self, forKeyPath: "valuechanges", options: .New, context: &myContext)
NSUserDefaults.standardUserDefaults().setValue("heychanges", forKey: "valuechanges")
NSUserDefaults.standardUserDefaults().synchronize()
2.
override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
if context == &myContext{
if let newValue = change![NSKeyValueChangeNewKey] as? NSString{
print("Value set \(newValue)")
}
}
}
Other are also experiencing the same or how is it?
Because same works fine in 9.2 and other lower only on 9.3 im getting issue .. Tried both on Simulator and phone.. same issue..
Thanks for help in advance