On 03/08/2009, at 4:07 PM, Deepa wrote:

I am developing an desktop app for which I want to implement a behavior which is similar to 'New from clipboard' of Preview application.

I tried using NSPasteboard:

// To get file copied to clipboard from Finder
NSArray *files = [[NSPasteboard generalPasteboard] propertyListForType: NSFilenamesPboardType];

This returns array of files copied to the clipboard

// To get tiff image
NSData *pbData = [[NSPasteboard generalPasteboard] dataForType: NSTIFFPboardType];
CIImage *pbImg = [CIImage imageWithData: pbData];

But this doesn't return null (tiff image data was copied to the clipboard).

Am I doing something wrong here???

Can someone help me out to sove this problem. I also wanted to know a method which copies and reads jpeg/gif/png image formats to/from system clipboard.


It's not clear what the problem is.

Do you want image data or not? Preview's 'New from clipboard' is looking for image data.

Normally when you read a pasteboard, you should pass it a list of types using -availableTypeFromArray:, where the array you give it indicates your *preferred order*. The type returned is the first matching type found, so if you prefer image data over file data, you list the image type first. It is up to the receiving application to set the preferred order, not the sending application, which has no idea who might make use of which copied data.

So if you want to read an image, you might prefer the order PDF, TIFF, File... then deal appropriately with whichever one you get back.

--Graham


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to