Chapter 10. File Management

This chapter covers the topic of file management. Here, you learn how to use both high- and low-level techniques for storing/retrieving data to/from files. To perform high-level operations on files/directories you use instances of the NSFileManager class. NSFileHandle class is used in this chapter to demonstrate low-level file access.

Section 10.1 covers the Home directory of the application. Next, Section 10.2 shows how to enumerate the contents of a given directory using the high-level methods of NSFileManager. In that section, you learn more about the structure of the Home directory and where you can store files. After that, you learn in Section 10.3 how to create and delete directories. Next, Section 10.4 covers the creation of files. Section 10.5 deals with the topic of file and directory attributes, and you learn how to retrieve and set specific file/directory attributes. In Section 10.6, we demonstrate the use of application bundles and low-level file access. Finally, we summarize the chapter in Section 10.7.

The Home Directory

The application and its data are contained within a single directory called the Home directory. Your application can only access this directory and its contents. The absolute path of the home directory on the simulator is different from that on the actual device. However, the organization and content are identical.

To access the absolute path of the Home directory, you can use the function NSHomeDirectory() which is declared ...

Get iPhone SDK 3 Programming: Advanced Mobile Development for Apple iPhone and iPod touch 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.