Apps can use file packages to implement complex file formats that contain multiple distinct files, or a mixture of different types of files.
Mac os screensaver program files how to#
An unarchiver reverses the process, using the stream of bytes to re-create the objects and restore them to their previous state.Īrchives are often a convenient alternative to implementing custom binary file formats for your documents or other data files.įor information on how to create and read archive files, see Archives and Serializations Programming Guide.Ī file package is a directory that contains any number of custom data files but which is presented to the user as if it were a single file. An archiver object encodes the state of the objects into a stream of bytes that can be written to disk all at once. You typically load the contents of a text file into an NSString object but may also read and write a text file as a raw stream of characters.įor information about using the NSString class to load text from a file, see String Programming Guide.Ī structured data file usually consists of string-based data arranged using a set of special characters.įor information about parsing XML, see Event-Driven XML Programming Guide.īinary files created using a keyed archiver objectĪn archive is a file format used to store a persistent version of your app’s runtime objects. The process for reading data from a resource file depends on the resource type.įor information about how to read the contents of resource files, see Resource Programming Guide.Ī text file is an unstructured sequence of ASCII or Unicode characters. Resource files are commonly used to store localizable content such as strings and images.
Mac os screensaver program files code#
Table 2-1 File types with specialized routinesĪpps use resource files to store data that is independent of the code that uses it. Table 2-1 lists the common file types supported by the system along with information about how you access them. For these standard file formats, use the higher-level options for reading and writing the file contents. macOS and iOS provide built-in support that makes opening many types of standard file formats (such as text files, images, sounds, and property lists) much easier. Choose the Right Way to Access FilesĪlthough you can open any file and read its contents as a stream of bytes, doing so is not always the right choice. For custom file types, you may need to read the raw file data yourself. For known file types, you typically use built-in system routines to read or write the file contents and give you an object that you can use.
Depending on the type of file, you may have several options. When you know the location of a file, you can then start planning the best way to access it. You can also specify locations manually by building a URL or string-based path from known directory names. The system frameworks provide many routines for obtaining references to many well-known directories, such as the Library directory and its contents. Next Previous Accessing Files and Directoriesīefore you can open a file, you first have to locate it in the file system.