Type of NSData contents
Type of NSData contents
- Subject: Type of NSData contents
- From: Ben <email@hidden>
- Date: Sat, 12 Jun 2010 13:18:47 +0100
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 (email@hidden)
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:
This email sent to email@hidden