When you need small sets of static, structured data for your Mac or iPhone projects, the most common approach is to bundle a Property List (or plist) file in your app. Any object-graphs made solely of ‘property-list objects’ – i.e. instances of NSArray, NSDictionary, NSString, NSData, NSDate or NSNumber – can be easily converted to or from serialised data formats, which means that they can be trivially read from or written to files or network sockets. For more information on plists, see Apple’s Property List Programming Guide.
Something that comes up regularly in iPhone development is the need to convert NSNumber objects to NSString objects and vice versa. For converting an NSNumber to an NSString, there is the -stringValue method, which is useful if you want just the plain number without any extra formatting. This isn’t particularly useful for presenting numbers in a user interface however, since -stringValue doesn’t give you any control over how the number is formatted.
If you use Shaun Inman’s Mint stat tracking software on a WordPress based site, as I do on Forge Code, you probably use the Bird Feeder Pepper. This ‘Pepper’ – the name given to Mint plugins/widgets – tracks the number of hits on your RSS feeds. The normal way to get Bird Feeder to collect this data is to manually modify the content of the PHP template file(s) in WordPress that are used to generate the content of your RSS feeds.
The first few times I tried developing a Preference Pane in OS X, I had more than a few head-scratching, “what the heck do I do now?” kind of moments. Unlike a typical Mac OS X or iPhone project in Xcode, when you create a Preference Pane project from the built-in Xcode template, doing a ‘Build and Run’ doesn’t result in your project being run. In fact, as of Xcode 3.2.1 the ‘Build and Run’ item in the ‘Build’ menu is disabled ‘out of the box’. This is due to the fact that your project isn’t building an executable program, it’s building a .prefPane bundle/plug-in.
Getting ‘Build and Run’ (⌘+R) to work as you might expect for a PrefPane project (by building your .prefPane, then installing it in System Preferences.app and loading it) isn’t hard, but it’s not at all well documented.
Older posts can be found in the archive.