Bug 7442 - UIPasteboard.Images is broken in iOS6
Summary: UIPasteboard.Images is broken in iOS6
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.99.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-09-25 09:08 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2012-10-04 20:20 UTC (History)
3 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 Rolf Bjarne Kvinge [MSFT] 2012-09-25 09:08:51 UTC
In iOS6 UIPasteboard.Images throws an exception:

"System.InvalidCastException: Unable to cast object of type 'MonoTouch.Foundation.NSObject' to type 'MonoTouch.UIKit.UIImage'.
 at MonoTouch.Foundation.NSArray.ArrayFromHandle[UIImage] (IntPtr handle) [0x00000] in <filename unknown>:0
 at MonoTouch.UIKit.UIPasteboard.get_Images () [0x00008] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIPasteboard.g.cs:694

This is because the underlying NSArray is populated with NSData objects instead of UIImage objects (contrarary to what the documentation [1] says: "The value stored in this property is an array of UIImage objects").

Here is code to work around this issue: https://gist.github.com/3781627

[1] http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIPasteboard_Class/Reference.html#//apple_ref/occ/instp/UIPasteboard/images
Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-10-04 20:20:18 UTC

master: 5a5a28901d8d9ab6f9bac8b55662cc73a5280d27
ios6: 35c719f97ec6581758014a3d95423bafcccc0e0f.