One More Thing: Checking for Available Disk Space

The NSFileManager class enables you to determine how much space is free on the iPhone and how much space is provided on the device as a whole. Listing 14-1 demonstrates how to check for these values and show the results using a friendly comma-formatted string. The values returned represent the total and free space in bytes.

Listing 14-1 Recovering File System Size and File System Free Size

- (void)logFileSystemAttributes {     NSFileManager *fm = [NSFileManager defaultManager];     NSDictionary *fsAttr =         [fm attributesOfFileSystemForPath:NSHomeDirectory()             error:nil];     NSNumberFormatter *numberFormatter =         [[NSNumberFormatter alloc] ...

Get The Core iOS Developer’s Cookbook, Fifth Edition 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.