Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
- Subject: Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]
- From: "Adam R. Maxwell" <email@hidden>
- Date: Thu, 22 May 2008 17:53:09 -0700
On May 22, 2008, at 5:08 PM, Quincey Morris wrote:
On May 22, 2008, at 16:37, Lynn Barton wrote:
I can't get the OSType code
with the key NSFileHFSTypeCode. Each time I try to access this data
I get a
different result
Is it perhaps something to do with the fact that [fileAttributes
objectForKey: NSFileHFSTypeCode] is documented to be a NSNumber
object, so the actual type code would be [[fileAttributes
objectForKey: NSFileHFSTypeCode] intValue]?
Since it's documented as returning an unsigned long, I'd use -
unsignedLongValue or -[NSDictionary fileHFSTypeCode] which returns an
OSType directly.
The OP also asked about converting this to a string, which you can do
with NSFileTypeForHFSTypeCode() or UTCreateStringForOSType() if you're
working with UTIs. Doing a Spotlight search for kMDItemContentType ==
public.plain-text might make more sense than iterating directories,
unless you're only looking for files with a type code.
--
adam
_______________________________________________
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