UIPasteboard images property not always returning an array of UIImages.

Originator:abizern
Number:rdar://12401014 Date Originated:29/09/2012
Status:Duplicate of 12131505 Resolved:
Product: Product Version:iOS6
Classification:Bug Reproducible:Always
 
Summary:

The documentation for the UIPasteboard images property states that it contains an array of UIImage objects.

This is correct when setting the items programmatically, but in cases where images were copied from the photo gallery (using the sharing functionality) then the images property contains an array of NSData objects (_NSCFData)

This isn't what the documentation says

Steps to Reproduce:

I have included a sample application with two screens.

If you start the app and press the copy button and then go to the next screen and paste the items- all is well. I am programmatically putting the images into the pasteboard's images property and pulling them out (although in reverse order) and putting them in new imageviews.

Now, open the photo gallery application, and using the share button, copy two (or more images). Start the PasteboardTest app again and go to the second view WITHOUT pressing the copy button. Now when you touch the Paste button - the app tries to pop images off the images array, but gets NSData, and crashes.

Expected Results:

Either UIImage objects or nil. I know that it isn't safe to assume that the user has put images onto the pasteboard and not text and a dev should be careful about making assumptions about what is in the pasteboard. But if the method is documented to return UIImage objects, and it has the capacity to return something else, then something is wrong IMHO.

Actual Results:

The images property can return UIImage objects as well as NSData objects.

Regression:

Notes:

I've attached PasteboardTest. A sample iOS6 app which demonstrates this.

(For the benefit of OpenRadar readers - http://goo.gl/2qnrQ

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!