O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required