Data / File Management
iOS Developer Tips - Visitor Stats:
|
|
|
Delete All Files in Documents Directory
In a recent project, I was using iTunes File Sharing to store various log files and test data. Although you can quickly delete all the files in the Documents directory using iTunes, I also was looking for a way to clean up the same directory when my device was not connected. The first approach I [...]
Preview Documents Tutorial with QLPreviewController
For the past few months I’ve been meaning to spend some time to check out the quick look document previewer on iOS – what follows is a short app that I wrote to get familiar with the QLPreviewController API. For those unfamiliar with the quick look previewer, it is a framework that provides quick previewing [...]
Get Total and Free Space on the Mounted File System
I recently was writing code to manage the download and storing of mp4 files to enable an application to play movies off-line. One consideration when dealing with files of significant size (50-100 megs) is disk space availability – this tip shows the method I called to get information about the mounted file system. Get Free [...]
Read Files from the Application Bundle
Below are a few lines of code to get you started if you need to open and read a file that is stored in the application bundle. Files could be anything from help text that your application displays to specific content that facilitates testing. As an example of the later, often times I find it [...]
Save UIImage Object as a PNG or JPEG File
In an earlier post on saving images from the camera to the Photo Album, a question was posed asking how to save the image to another directory other than the Photo Album. Let’s walk through one way to write a UIImage object, from the camera or otherwise, as a PNG or JPG file into the [...]
Read and Write Array, Dictionary and Other Collections to Files
With just a few lines of code, you can read/write collections to/from files. The code below shows examples for writing and reading back both arrays and dictionaries. Read and Write Collections to File NSArray *array = [NSArray arrayWithObjects: @"Hefeweizen", @"IPA", @"Pilsner", @"Stout", nil]; NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys: array, @"array", @"Stout", @"dark", @"Hefeweizen", @"wheat", [...]
Reading a plist into an NSArray
Reading a plist into an NSArray This is the second tip in a series of four that is based on content from the O’Reilly book Head First iPhone Development. The first tip described how to adjust textfields that are hidden when the onscreen keyboard is shown.
iPhone File System: Creating, Renaming and Deleting Files
The iPhone provides a comprehensive set of operations for working with files and directories. NSFileManager includes methods for querying the contents of directories, creating, renaming and deleting contents, as well as getting/setting file attributes (readable, writeable, etc). Point to the Documents Directory Each application has its own sandbox in which you can read/write files. Files [...]
Get Users Home Directory – Part 2
In the previous tip on working with plists, I showed an example of how to create a path to a file to be stored in the /Documents folder. In this tip I want to show an example that arrives at the same end result, however, I’ll use methods which will eliminate the hardcoding of paths [...]
Get Users Home Directory – Part 1
In a recent application I needed to create several property list files (plists) to store application information. I opted to store the files in the folder named “Documents” off the home folder. Here is the code I used to specify the path where I wanted the files written and the code to build an NSString [...]






