I'm pretty new to Objective-C, but have been mostly understanding everything so 
far. I am stuck, however, on trying to share an animated GIF through 
NSSharingService.
I am attaching the image like so, where “image" is a string containing the URL 
of an animated GIF (http://i.imgur.com/V8w9fKt.gif, for example):

NSImage *imageData = [[NSImage alloc] initWithContentsOfURL:[NSURL 
URLWithString:image]];
NSArray *shareItems = [NSArray arrayWithObjects:imageData, @“Text", nil];
NSSharingService *service = [NSSharingService 
sharingServiceNamed:NSSharingServiceNameComposeMessage];
service.delegate = self;
[service performWithItems:shareItems];

When the code is run and the message is sent, however, the image gets sent as a 
PNG file instead of a GIF.

I found a GitHub repo (https://github.com/glebd/ImageSharingTest/) which was 
attempting to answer a similar problem. A solution was never found, however, 
but the last bit of advice was:

However, when I add an NSAttributedString with a GIF attachment 
toNSSharingServicePicker, the shared image is not animated. I can't add the 
wrapper RTFD data to the picker, as it can only share objects that support 
NSPasteboardWriting protocol, and the RTFD is returned as NSData.
Copying RTFD data to pasteboard as NSRTFDPboardType works and preserves 
animation

Would it be possible to convert the GIF to an RTDF object, copy it to the 
pasteboard, retrieve the pasteboard item, then share that object? Or is there 
another solution to sharing animated GIFs with NSSharingService?

Charles Carver
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to