MonoTouch NSNotificationCenter.DefaultCenter.AddObserver now deprecated?

I'm just wondering what the modern equivalent is:

NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", receivedRotate);

will be. He says that it is deprecated and that I should use AddObserver, but I'm not sure what IntPtr var to use for context.

+3
source share
1 answer

You don't need the IntPtr option, if you are reading an obsolete method, it says:

"Use AddObserver (NSString, Action) instead"

So you want

NotificationCenter.DefaultCenter.AddObserver (UIDevice.OrientationDidChangeNotification, receivedRotate);
+7
source

Source: https://habr.com/ru/post/1782222/


All Articles