Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode]




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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode] (From: Lynn Barton <email@hidden>)
 >Re: Can't get file type code using [fileAttr valueForKey:NSFileHFSTypeCode] (From: Quincey Morris <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.