O'Reilly logo

iOS 8 Swift Programming Cookbook by Vandad Nahavandipoor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. Files and Folder Management

14.0. Introduction

iOS is based on OS X, which itself is based on the Unix operating system. In iOS, the operating system’s full directory structure is not visible to an app because each app, written by an iOS app developer, lives in its own sandbox. A sandbox environment is exactly what it sounds like: a sanctioned area where only the app that owns the sandbox can access the contents of the folder. Every app has its own sandbox folder and the sandbox folders by default have subfolders that apps can access.

When an iOS app is installed on the device, the folder structure shown in Figure 14-1 will be created for that app by the system.

Name.app

Despite the odd name with the .app extension, this is a folder. The contents of your main bundle all go in here. For instance, all your app icons, your app binary, your different branding images, fonts, sounds, etc., are placed in this folder automatically when iOS installs your app on a device. The name is the product name that you set for your app. So if your app is called MyApp, the .app folder will be called MyApp.app.

Documents/

This folder is the destination for all user-created content. Content that your app has populated, downloaded, or created should not be stored in this folder.

Library/

You use this directory to store cached files, user preferences, and so on. Usually, this folder on its own does not contain files. It contains other folders that contain files.

Figure 14-1. Depiction of the iOS filesystem ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required