Bug 31760 - canReadObjectForClasses:options and readObjectsForClasses:options on NSPasteBoard just don't work
Summary: canReadObjectForClasses:options and readObjectsForClasses:options on NSPasteB...
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: PC Mac OS
: High normal
Target Milestone: 2.4.0 (C6)
Assignee: Chris Hamons
Depends on:
Reported: 2015-07-08 15:41 UTC by Chris Hamons
Modified: 2015-10-14 15:39 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 Chris Hamons 2015-07-08 15:41:48 UTC
These APIs need a NSArray of Class's that implement INSPasteboardReading, not an array of the instances. The API is unusable until we fix this:


		[System.Runtime.InteropServices.DllImport ("/usr/lib/libobjc.dylib", EntryPoint="objc_msgSend")]
		public extern static global::System.IntPtr IntPtr_objc_msgSend_IntPtr_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1, IntPtr arg2);

		[System.Runtime.InteropServices.DllImport ("/usr/lib/libobjc.dylib", EntryPoint="objc_msgSend")]
		public extern static bool bool_objc_msgSend_IntPtr_IntPtr (IntPtr receiver, IntPtr selector, IntPtr arg1, IntPtr arg2);

			NSPasteboard pasteboard = NSPasteboard.GeneralPasteboard;
			NSArray classArray = NSArray.FromObjects (new Class ("NSImage"));

			bool ok = bool_objc_msgSend_IntPtr_IntPtr (pasteboard.Handle, Selector.GetHandle ("canReadObjectForClasses:options:"), classArray.Handle, IntPtr.Zero);
			if (ok) {
				NSObject [] objectsToPaste = NSArray.ArrayFromHandle<Foundation.NSObject>(IntPtr_objc_msgSend_IntPtr_IntPtr (pasteboard.Handle, Selector.GetHandle ("readObjectsForClasses:options:"), classArray.Handle, IntPtr.Zero));
				NSImage image = (NSImage)objectsToPaste[0];
				Console.WriteLine (image.Size);
				// Do something with image
Comment 1 Chris Hamons 2015-07-16 16:15:13 UTC
Fixed in master / e53f89193a051d95da82159ea6ecceb9b0b39936
Comment 2 Rajneesh Kumar 2015-10-08 14:55:01 UTC

To verify this issue I have tried to reproduce this issue but I am not sure about the steps to reproduce. So could you please share the steps/sample to reproduce this issue. So I can reproduce and verify this issue at our end efficiently.

Comment 3 Chris Hamons 2015-10-14 15:39:13 UTC
This bug was just pointing out that the APIs took the wrong type and were thus unusable. I verified the API changes with the apidiff tool already.