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
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 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