Re: NSHFSTypeCodeFromFileType troubles
Re: NSHFSTypeCodeFromFileType troubles
- Subject: Re: NSHFSTypeCodeFromFileType troubles
- From: Ali Ozer <email@hidden>
- Date: Thu, 7 Mar 2002 13:09:48 -0800
These functions are not meant for converting type codes back and forth
from string representations, so you might be misusing them.
NSFileTypeForHFSTypeCode() is used to create NSStrings from Mac OS type
codes; NSStrings which can be passed to Cocoa APIs that expect file
extensions, to get them to also recognize Mac OS type codes.
NSHFSTypeCodeFromFileType() does the reverse; assuming you pass it an
NSString created with NSHFSFileTypeFromTypeCode(), it returns the type
code that was used.
The fact that the string representation that is used has single-quotes
is supposed to be an implementation detail. Unfortunately one that would
be hard to change, but an implementation detail nevertheless...
Ali
On Thursday, March 7, 2002, at 12:13 PM, Chris Gervais wrote:
Ah...I didn't even think to include the single quote as I thought that
NSHFSTypeCodeFromFileType just took the string as it was...the doc
needs to
be more clear on this!
Well OSTypes are just a 4 characters string const, like 'JPEG'.
An file type right now for an HFSfile type(OSType) is encode like
@"'JPEG'",
note the single quotes this is important.
Thanks,
Andrew Pinski
On Thursday, March 7, 2002, at 01:54 , Chris Gervais wrote:
So I'm trying to use the nifty Foundation function
NSHFSTypeCodeFromFileType() which doesn't appear to be a difficult
endeavor.
NSHFSTypeCodeFromFileType is supposed to turn NSStrings into OSTypes.
Cool.
However, I've tried passing several NSStrings into it, yet it always
returns
zero. The length of the strings are four characters and I've even
tried a
gimme like NSHFSTypeCodeFromFileType(@"JPEG") but I'm always getting
zero
back.
Is there any hidden trick here or am I just missing something
super-obvious?
I was hoping that this function would be a quick way to create some
OSTypes
for me to pass along to various Carbon functions rather than having to
write
an NSString->OSType function, which, granted, isn't hard, but is just
one
more thing I didn't want to write. Of course, I probably could have in
the
time it took to write this message. Hmmm...is it too early for a
cocktail?
Thanks,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.