Bug 16279 - UILayoutSupportWrapper needs to extend NSObject
Summary: UILayoutSupportWrapper needs to extend NSObject
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 7.0.4.x
Hardware: PC Mac OS
: Normal normal
Target Milestone: 7.2.0 (iOS 7.1)
Assignee: Bugzilla
: 16920 ()
Depends on:
Reported: 2013-11-15 15:35 UTC by Jérémie Laval
Modified: 2014-09-10 07:42 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jérémie Laval 2013-11-15 15:35:09 UTC
As returned by UIViewController.(Top|Bottom)LayoutGuide otherwise you can't use them in NSLayoutConstraint.Create which is what they are for.
Comment 2 Rolf Bjarne Kvinge [MSFT] 2013-11-18 08:59:46 UTC
UILayoutSupportWrapper can't inherit from NSObject, because it would mean we could end up with multiple managed wrappers for the same native object (which breaks us badly).

But we can fix NSLayoutConstraint.Create to accept INativeObject as well.
Comment 3 Jérémie Laval 2013-11-18 09:03:11 UTC
That would solve this one indeed but then who knows which other API (or just the client wanting to pass around the object in existing code) will then require fixing.

If it's impossible to make it inherit from NSObject, couldn't we add a cast operator or method to convert it to NSObject?
Comment 4 Rolf Bjarne Kvinge [MSFT] 2013-11-18 09:06:19 UTC
You can use ObjCRuntime.Runtime.GetNSObject (iface.Handle) if you really need an NSObject.

However please file enhancement requests if you find any API that takes NSObject and should accept these interfaces, we need to fix these cases.
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-12-05 10:09:25 UTC
Fixed (by adding a NSLayoutConstraint.Create overload that takes INativeObjects).

monotouch/master: 3e299bf247055480bf7096a45df5dd7f8fc711e5
Comment 6 Rolf Bjarne Kvinge [MSFT] 2013-12-20 17:50:23 UTC
*** Bug 16920 has been marked as a duplicate of this bug. ***
Comment 7 Rolf Bjarne Kvinge [MSFT] 2014-09-10 07:42:21 UTC
Fixed in comment #5.