Re: Can I put UTIs in NSFilesPromisePboardType promise drag array?
Re: Can I put UTIs in NSFilesPromisePboardType promise drag array?
- Subject: Re: Can I put UTIs in NSFilesPromisePboardType promise drag array?
- From: Jim Correia <email@hidden>
- Date: Sun, 5 Oct 2008 09:15:38 -0400
On Oct 5, 2008, at 12:44 AM, Nathan Vander Wilt wrote:
I'm not sure what you mean here. The documentation for promise drags
says to encode the OSType using NSFileTypeForHFSTypeCode() which in
my testing just turns the "characters" the programmer sees in their
source into a string (ie 'uint' becomes @"uint"). As extensions
could be any number of characters, how would I know if "docx" is the
exension of a new Office document or maybe some old OSType code
registered decades ago for a totally different format?
Actually, four char codes are encoded in single quotes. (But you
shouldn't rely on that; just use the provided API) So you can do the
following when going through the list of types:
OSType hfsType = NSHFSTypeCodeFromFileType(filetype);
if (hfsType != 0) {
/* treat as for char code */
} else {
/* treat as filename extension */
}
What initially bothered me about the lack of UTI support was that I
have no idea what the HFS types were, except for 'GIFf' and 'TEXT'
which show up as canonical OSType examples throughout the docs. Of
course, since I can use extensions that's mostly a a non-issue,
though I do wonder what I'd do if another app gives me HFS types
instead of extensions.
If your source data is an HFS type, you can use the provided API to
encoding it as an NSString. In addition, there is API to go between
filename extension, HFS type, and UTI as necessary.
Jim
_______________________________________________
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