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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.