The iOS6 sdk has some changes to it. Along with these changes come changes to the UIPasteboard. One thing is the UIPasteboard now handles most images as NSData.
Here is my solution to accessing and setting images in the UIPasteBoard.
Accessing Images:
for (NSObject* obj in [UIPasteboard generalPasteboard].images) {
if ([obj isKindOfClass:[NSData class]]) {
UIImage* img = [[UIImage alloc] initWithData:(NSData*)obj];
} else if ([obj isKindOfClass:[UIImage class]]) {
UIImage* img = (UIImage*)obj;
}
}
I saw in a comment that setImages: is not functional, here is a fix:
Setting Images:
for (UIImage* img in myImagesArray) {
NSData* imageData = UIImageJPEGRepresentation(img, 1);
NSMutableDictionary *item = [NSMutableDictionary dictionary];
[item setValue:imageData forKey:(NSString*)kUTTypeJPEG];
[[UIPasteboard generalPasteboard] addItems:[NSArray arrayWithObject:item]];
}
OMG you are awesome!
I have been struggling with this all day!
Thank you thank you thank you !