Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

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 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>