fileType - NSFileType
Returns the value for the key
NSFileType
.
- (NSString *)fileType
Return Value
The value for the key
NSFileType
, or nil
if the dictionary doesn’t have an entry for the key.Discussion of [NSDictionary NSFileType]
This and the other
file...
methods are for use with a dictionary, such as those returned from the methods fileAttributesAtPath:traverseLink:
(NSFileManager
), directoryAttributes
(NSDirectoryEnumerator
), and fileAttributes
(NSDirectoryEnumerator
), that represents the POSIX attributes of a file or directory. This method returns the file’s type. Possible return values are described in the “Constants” section of NSFileManager
.
Example of [NSDictionary NSFileType]
NSFileManager *filemgr;
NSDictionary *attribs;
filemgr = [NSFileManager defaultManager];
attribs = [filemgr attributesOfItemAtPath: @"/tmp" error: NULL];
NSLog (@"Created on %@", [attribs objectForKey: NSFileCreationDate]);
NSLog (@"File type %@", [attribs objectForKey: NSFileType]);
NSLog (@"POSIX Permissions %@", [attribs objectForKey: NSFilePosixPermissions]);
Example of [NSDictionary NSFileType]
NSFileManager *fm = [NSFileManager defaultManager];
NSError *error = nil;
NSDictionary *attr = [fm attributesOfItemAtPath:@"/" error:&error];
if (!error) {
NSLog(@"Attr: %@", attr);
}
2009-10-28 17:21:11.936 MyApp[33149:a0b] Attr: {
NSFileCreationDate = "2009-08-28 15:37:03 -0400";
NSFileExtensionHidden = 0;
NSFileGroupOwnerAccountID = 80;
NSFileGroupOwnerAccountName = admin;
NSFileModificationDate = "2009-10-28 15:22:15 -0400";
NSFileOwnerAccountID = 0;
NSFileOwnerAccountName = root;
NSFilePosixPermissions = 1021;
NSFileReferenceCount = 40;
NSFileSize = 1428;
NSFileSystemFileNumber = 2;
NSFileSystemNumber = 234881026;
NSFileType = NSFileTypeDirectory;
}