Hi list

Given an NSData object, with no context as to what it might be, is it possible 
to find if it contains a document of recognised file type?

I know this is possible for image files, by using the imageIO framework and 
doing the following:

CGImageSourceRef imageSource = 
CGImageSourceCreateWithData(myNSDataObjectGoesHere, NULL);
NSString *uti = (NSString *)CGImageSourceGetType(imageSource);
NSString *extension = [[NSWorkspace sharedWorkspace] 
preferredFilenameExtensionForType:uti];
CFRelease(imageSource);
// Standard typed-in-mail-disclaimer here


I suppose I could take the long route of writing the data to disk, then using 
the NSWorkspace method -typeOfFile:error:, but that seems a bit heavy-handed.

Can anyone suggest a better way of doing this? I've been unable to find 
anything in the archives or Google, but perhaps I'm using the wrong search 
terms.

- Ben

_______________________________________________

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