Forum Xamarin.Forms

Forms app on iOS - AppDelegate does not have access to window selector

DavidShawDavidShaw USMember ✭✭

When you make an Xamarin forms app, the iOS target app's AppDelegate inherits from a base class as follows:

public class AppDelegate : Xamarin.Forms.Platform.iOS.FormsApplicationDelegate

The problem I am having is that we have some native code in a library that does the following:

UIWindow *mainWindow = [[UIApplication sharedApplication].delegate window];

In Xamarin this results in an error message:

Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[AppDelegate window]: unrecognized selector sent to instance 0x124dcd030

Is there a reason that the base class doesn't have access to the 'window' selector, and could this be remedied, either in my own AppDelegate subclass or in the Xamarin.Forms.Platform.iOS.FormsApplicationDelegate base class?


Sign In or Register to comment.