Chapter 9. File Management
This chapter covers the topic of file management. Here, you will 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.
In Section 9.1 we talk about the Home
directory of the application. Next, Section 9.2 shows how to enumerate the contents of a given directory using the high-level methods of NSFileManager
. In that section, you will learn more about the structure of the Home
directory and where you can store files. After that, we learn in Section 9.3 how to create and delete directories. Next, Section 9.4 covers the creation of files. Section 9.5 deals with the topic of file and directory attributes, and you will learn how to retrieve and set specific file/directory attributes. In Section 9.6 we demonstrate the use of application bundles and low-level file access. Finally, we summarize the chapter in Section 9.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 call NSHomeDirectory() ...
Get iPhone SDK Programming: Developing Mobile Applications 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.