mac_ch10.eps
co_bar.eps

Chapter 10: Working with Files, URLs, and Web Data

mac_chbox10.eps

In This Chapter

Creating and using file paths

Creating and using URLs

Using Web APIs

Using WebView

Cocoa's file handling is unusual. In most operating systems, files are managed by calling a file manager object. In Cocoa, data objects can read and write data directly. A separate file manager is only required when you need to delete, copy, rename, or move files under program control.

mac_note.eps Note

Cocoa's NSFileManager class can be used to access stdio — the default system i/o channel. It also supports nonlinear file reads, making it possible to extract bytes from a while without loading it into memory.

For example, NSString has methods for reading and writing string data to files; NSDictionary can read and write dictionaries; and so on. Typically an initWithContentsOfFile: method initializes a data object with the contents of a file specified by a path string that points to a unique location in the file system. A corresponding writeToFile: method writes data.

For completely general file access, the NSCoder class described in the Chapter ...

Get Cocoa® 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.