Quantcast
Channel: Xamarin.Mac — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 1429

Problems when adding observer to StandardUserDefaults

$
0
0

Hi,

I need to get notified if user changes macOS theme. I can get the current theme with:

var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle");

I want to be notified when user changes the theme so I added observer to StandardUserDefaults in my AppDelegate constructor:

themeObserver = NSUserDefaults.StandardUserDefaults.AddObserver("AppleInterfaceStyle", NSKeyValueObservingOptions.New, this.HandleAction) as NSObject;

Problem: After starting application, first time I change the theme I get the event with few seconds delay and after that the delay gets even longer. It feels quite random when I get the event.

Any suggestions?

Thanks!


Viewing all articles
Browse latest Browse all 1429

Latest Images

Trending Articles



Latest Images