Monday 15 August 2011

xcode6 - Why might this [Swift] NSObject.addObserver registration not be calling func observeValueForKeyPath() as expected? -


The problem code is as follows. [I hope] the problem is completely outlined in the above question. Thanks in advance. MJB UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {var some_string: NSString = "One" Fun Application (Application: UIApplication, didFinishLaunchingWithOptions Launch Options: [NSObject: AnyObject]?) - & gt; (Prefetch: "some_string", option: zero, references: zero) self.some_string = "two" return true} View override fonts ValueForKeyPath (keyPath: print_n ("init ...") self.addObserver (for self, String, ofObject Object: Any object, change: [NSObject: OOBEZ], contact: asphosphal pointers

  • , you have to dynamic Keywords must use:

      dynamic variable some_string: NSString = "one"  

    In addition to this, > NSObject , although in your case it will be UIResponder .


    No comments:

    Post a Comment