$aleOrigin

Data / File Management

Please consider subscribing to Mobile Developer Tips
RSS feed or following us on Twitter


Sort A Dictionary By Value Of Each Key-Value Pair

You can sort the values in a dictionary using the method keysSortedByValueUsingSelector:. The result is an array of keys from the dictionary, which represent the sorted values of the key-value pair. Let’s say for example that you have a dictionary that has key-value pairs with an account name and balance: NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: [...]

Data / File Management

Add Comma Separators to Numbers

Seems a common question, how can I format a number such as 123456 to look like 123,456? The NSNumberFormatter makes this quite easy. NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle];   double d = 234567.89; int i = 1234567890;   NSString *strFloat = [formatter stringFromNumber:[NSNumber numberWithDouble:d]]; NSString *strInt = [formatter stringFromNumber:[NSNumber numberWithInt:i]];   [...]

Data / File Management

Get Image Data Including Depth, Color Model, DPI and More

Although you can get some basic information if you load an image into a UIImage object, at times it can be helpful to more about an image, for example, the color model (RGB, CMYK, Gray…), resolution in dots-per-inch (DPI), etc. One way to gather such information is through a CGImageSource object. Often times this object [...]

Data / File Management

Overview of iOS Application Directories

iOS applications have a limited number of directories available for writing content, the design intent is to ensure application security. This post will give a quick run down of the folder locations available in an iOS application and their intended use. Documents Directory – ApplicationHome/Documents The Documents directory is the primary location to save user [...]

Data / File Management

Count The Number of Words in a String

Here’s a quick way to count the number of words in an NSString object. The trick is to use the character set whitespaceAndNewlineCharacterSet which will look for spaces, tabs and newline characters. – (NSUInteger)wordCount:(NSString *)str { NSUInteger words = 0;   NSScanner *scanner = [NSScanner scannerWithString: str];   // Look for spaces, tabs and newlines [...]

Data / File Management

Register File Types to Associate File Extension with an App

If you would like other applications to open your app based on a file type, you can register your document request in the application plist file. Include the CFBundleDocumentTypes key, which is an array of dictionaries, where each entry defines information about the file type(s) your app supports. Let’s look at a typical definition:

Data / File Management

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 [...]

Data / File Management

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 [...]

Data / File Management

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 [...]

Data / File Management
All Content Copyright © 2008-2012 • Mobile Developer Tips, All Rights Reserved.
iPhone and iPad are registered trademarks of Apple, Inc.
iOS is a registered trademark of Cisco Technology, Inc.