Bug 11228 - Odd little discrepancy with MonoTouch.UIKit.NSLayoutConstraint.Priority
Summary: Odd little discrepancy with MonoTouch.UIKit.NSLayoutConstraint.Priority
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.2.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-03-18 10:44 UTC by Joseph Remes
Modified: 2013-03-19 11:32 UTC (History)
2 users (show)

Tags:
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:
Status:
RESOLVED FEATURE

Description Joseph Remes 2013-03-18 10:44:19 UTC
There seems to be a type mismatch for the MonoTouch.UIKit.NSLayoutConstraint.Priority property.
It is supposed to be one of the enum UILayoutPriority. But the compiler is requiring me to explicitly
cast to float if like this...
MyConstraint.Priority = (float)UILayoutPriority.Required;

Is this correct? Feels like it should not require the cast.

I am using the latest stable release of Xamarin Studio (4.0.1). It reports that I am using Xamarin.iOS version 6.2.0.65
Comment 1 Joseph Remes 2013-03-18 17:57:22 UTC
Oddity still here in 4.0.2
Comment 2 Sebastien Pouliot 2013-03-19 11:32:59 UTC
You're right, it is an oddity. 

> Is this correct?

Yes, this happens because Objective-C allows floats as a valid enum type while this is not possible on .NET. It's not common but UILayoutPriority [1] is one of the few cases.

enum {
   UILayoutPriorityRequired = 1000,
   UILayoutPriorityDefaultHigh = 750,
   UILayoutPriorityDefaultLow = 250,
   UILayoutPriorityFittingSizeLevel = 50,
};
typedef float UILayoutPriority;


[1] https://developer.apple.com/library/ios/#documentation/AppKit/Reference/NSLayoutConstraint_Class/NSLayoutConstraint/NSLayoutConstraint.html