Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int _MyVal;
- [Export("MyVal")]
- public int MyVal
- {
- get { return _MyVal; }
- set
- {
- WillChangeValue("MyVal");
- this._MyVal = value;
- DidChangeValue("MyVal");
- }
- }
- SettingsModel.AddObserver(this, (NSString)key, NSKeyValueObservingOptions.New, this.Handle);
- public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
- {
- switch (keyPath)
- {
- case "MyValue":
- // CODE HERE THAT UPDATES AN API WITH THE VALUE
- // But this handler fires twice.
- break;
- }
- }
- [Export("MyVal")]
- public int MyVal { get; set }
- this.SettingsModel.MyVal = 1;
- MainViewController.ObserveValue
- ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr()
- Foundation.NSObject.DidChangeValue(string forKey)
- CameraSettingsModel.set_MyValue(int value)
- AppKit.NSApplication.NSApplicationMain()
- AppKit.NSApplication.Main(string[] args)
- MainClass.Main(string[] args)
- MainViewController.ObserveValue
- AppKit.NSApplication.NSApplicationMain()
- AppKit.NSApplication.Main(string[] args)
- MainClass.Main(string[] args)
- [Export ("automaticallyNotifiesObserversForKey:")]
- public static new bool AutomaticallyNotifiesObserversForKey (string key) => false;
- bool _checkValue;
- [Export("CheckValue")]
- public bool CheckValue
- {
- get { return _checkValue; }
- set
- {
- WillChangeValue("CheckValue");
- _checkValue = value;
- DidChangeValue("CheckValue");
- }
- }
- public override void ViewDidLoad ()
- {
- base.ViewDidLoad();
- this.AddObserver("CheckValue", NSKeyValueObservingOptions.New, o =>
- {
- Console.WriteLine($"Observer triggered for {o}");
- });
- CheckValue = false;
Add Comment
Please, Sign In to add comment