Skip to content

Instantly share code, notes, and snippets.

@rolfbjarne
Created May 27, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rolfbjarne/ca32d9a84f9e42f4dc3d to your computer and use it in GitHub Desktop.
Save rolfbjarne/ca32d9a84f9e42f4dc3d to your computer and use it in GitHub Desktop.
[Category(typeof(NSLayoutConstraint))]
public static class DebugConstraint
{
[Export("description")]
public static string Description(this NSLayoutConstraint @this)
{
// XAMARIN: either of the below two lines causes a stackoverflow, presumably because this method is being invoked instead of the one defined by NSLayoutConstraint
//var result = @this.PerformSelector(new Selector("description"));
//var originalDescription = @this.Description;
objc_super super = new objc_super ();
super.receiver = @this.Handle;
super.@class = Class.GetHandle (typeof(NSLayoutConstraint).BaseType);
var result = Runtime.GetNSObject (objc_msgSendSuper (ref super, Selector.GetHandle ("description")));
Console.WriteLine ("desc: {0}", result);
return result.ToString ();
}
struct objc_super {
public IntPtr receiver;
public IntPtr @class;
}
[System.Runtime.InteropServices.DllImport ("libobjc.dylib")]
static extern IntPtr objc_msgSendSuper (ref objc_super super, IntPtr sel);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment