Chapter 17

File Loading and Saving

Many computer programs (applications) end up creating some kind of semi-permanent artifact of the user’s work. Maybe it’s an edited photo. Maybe it’s a chapter of a novel. Maybe it’s your band’s cover of “Free Bird.” In each of these cases, the user ends up with a saved file.

The standard C library provides function calls to create, read, and write files, such as open(), read(), write(), fopen(), and fread(). These functions are well documented elsewhere, so we won’t talk about them. Cocoa provides Core Data, which handles all this file stuff behind the scenes for you. We won’t be talking about this either.

So what does that leave us to discuss? Cocoa provides two general classes of file handling: property ...

Get Learn Objective-C on the Mac: For OS X and iOS, Second 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.