Search code examples
c#iosxamarin.iosautolayoutxamarin-studio

How to enter commands in the debugger of Xamarin Studio


I want to enter the following command into the debugger

po [[UIWindow keyWindow] _autolayoutTrace] 

How would I do that in Xamarin Studio?

Edit:

I saw this Objective-C code

NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);

in programatically change autolayout on orientation change together with an interface definition for that.

// for debugging auto layout.
@interface UIWindow (AutoLayoutDebug)
+(UIWindow *)keyWindow;
-(NSString *)_autolayoutTrace;
@end

I'd like to know how this can be done in Xamarin iOS?


Solution

  • using MonoTouch.ObjCRuntime;
    
    var str = new NSString (Messaging.IntPtr_objc_msgSend (UIApplication.SharedApplication.KeyWindow.Handle, new Selector ("_autolayoutTrace").Handle));
    

    And "str" will contain the string that you can then use with Console.WriteLine