File Metadata

There are a number of functions, system calls, and toolkit APIs for accessing file metadata. NSFileManager provides a path-based way to acquire metadata, as well as URL-based equivalents. The URL-based API actually exposes much more file metadata than the path-based one. Unfortunately, even though the URL-based metadata API is available on iOS, as of iOS 4.3, the methods return nil. So for iOS, you will need to stay with the path-based metadata API.

Metadata through paths

NSFileManager’s -attributesOfItemAtPath: returns a dictionary of attributes.

- (NSDictionary *) attributesOfItemAtPath: (NSString *) path
                                    error: (NSError **) error;

You can access these attributes through an NSDictionary category, of which a subset is shown below. ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.