Bug 1666 - Unable to bind NSValue to .NET numeric data types
Summary: Unable to bind NSValue to .NET numeric data types
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
Depends on:
Reported: 2011-10-24 17:35 UTC by Shawn Lehner
Modified: 2011-10-26 15:53 UTC (History)
2 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 Shawn Lehner 2011-10-24 17:35:20 UTC
I am using the following notification binding:

NSNotificationCenter.DefaultCenter.AddObserver (new NSString("UIKeyboardWillShowNotification"), OnKeyboardShown, null);

And I am attempting to get the value of "UIKeyboardAnimationCurveUserInfoKey" and "UIKeyboardAnimationDurationUserInfoKey" into .NET data types from the NSValue objects returned by NSNotification. It was recommended by IRC users that I submit a bug for Miguel.

Comment 1 Shawn Lehner 2011-10-24 17:42:18 UTC
I just realized there is a "UIKeyboard.AnimationCurveFromNotification" method which should solve this issue. This seems like an odd/special case method. Please close this bug if this is intended.
Comment 2 Shawn Lehner 2011-10-24 17:53:12 UTC
Also, the UIKeyboard helper method of "UIKeyboard.FrameEndFromNotification" does not return the same value as "((NSValue)notice.UserInfo[new NSString("UIKeyboardFrameEndUserInfoKey")]).RectangleFValue" which I think it should.
Comment 3 Sebastien Pouliot 2011-10-26 15:44:25 UTC
Good catch (comment #2), a parameter was ignored leading to the wrong value being used.
Comment 4 Sebastien Pouliot 2011-10-26 15:53:36 UTC
fixed in c83016f832c1bc8e44b7b3d97d45ce34cac045df (master)

Your code should work fine until a newer MonoTouch is released (the one from MonoTouch presently always uses BoundsUserInfoKey).

As for comment #1 the method exists to provide an easier, type safe, version of what would be required for an 1-to-1 ObjectiveC port. You can still do it manually (like you did) but the extra methods feels more C#-py :-)