I submitted a new bug: NSFileManager does not accept NSString values for HFS types. it follows, edited only for HTMLification.
The following keys access file attribute values contained in NSDictionary objects used by changeFileAttributes:atPath:, fileAttributesAtPath:traverseLink:, createDirectoryAtPath:attributes:, and createFileAtPath:contents:attributes::
Steps to Reproduce:
/*1*/ NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys: NSFileTypeForHFSTypeCode('FOO!'), NSFileHFSTypeCode, NSFileTypeForHFSTypeCode('BAR!'), NSFileHFSCreatorCode, nil]; /*2*/ [[NSFileManager defaultManager] createFileAtPath:@"strings are our friends.txt" contents:[NSData data] attributes:attrs];
the file is successfully created and imbued with both of the desired attributes.
NSString throws an exception because it does not respond to -unsignedLong (yes, I know I got this selector wrong when I filed it — oops —ed), as assumed by NSFileManager.
NSFileTypeForHFSTypeCode appears to be the canonical way to create, effectively, an 'instance' of an HFS file type to be passed around in Cocoa, but NSFileManager only accepts NSNumbers. NSNumber seems to me to be more of a 'raw' representation. besides which, this usage of it definitely assumes the length of an unsigned long.