Skip to content

iOS development

XPathEval updated

February 7th, 2013


An update to XPathEval just became available. Support for iPhone 5, small bugfixes. Get it here: iTunes

Checking if an NSDictionary can be serialized into a .plist

April 22nd, 2012


Note: Although you could still use this for iOS 4 legacy projects, this has been rendered mostly useless by the JSON framework in iOS5

Here’s a little utility method I hadn’t seen floating around anywhere yet, so I decided it could make a useful blog post.

First of all I’d like to mention that you probably shouldn’t be using .plists as means of persistence. I do, because the app data for my current project comes mainly from a RESTful JSON service so it fits the bill for the .plist type.
Most likely though, if you are working with data of any complexity you should be making your classes NSCoding compliant, or ideally use Core Data. It’s a ridiculously powerful tool, learn it, master it, use it, love it. But on with the .plists…

When trying to save an NSDictionary to a .plist file in an app’s Documents directory, developers often run into unknown errors. Sadly, the writeToFile: atomically: call doesn’t take NSErrors as a parameter, so you’re left with a simple boolean telling you the write operation failed.

Possible reasons for failure include:

  • the specified file doesn’t exist
  • the NSDictionary contains values that can’t be saved to a .plist format
  • the NSDictionary contains keys that aren’t instances of NSString

What the below method does, is checking whether any of the second two points caused the operation to fail. It should be called after the operation has returned NO. All it does is iterate recursively over the entire dictionary and check if any invalid keys or objects are found. The example simply NSLogs errors, if you were to use this in production code, you should probably use a second collection to keep track of exactly what went wrong and collect those data using Flurry or your analytics suite of choice.

- (void)analyseObject: (NSObject *) object {
   if ([object isKindOfClass:[NSArray class]]){
      for (NSObject *arrayObject in (NSArray *)object){
         [self analyseObject:arrayObject];
   else if ([object isKindOfClass:[NSDictionary class]]){
      for (NSObject *dictObject in [(NSDictionary *) object allValues]){
         [self analyseObject:dictObject];

      for (NSObject *key in [(NSDictionary *) object allKeys]){
         if (![key isKindOfClass:[NSString class]]){
            NSLog(@"bad key found: %@", [key description]);
   else if (![object isKindOfClass:[NSString class]] &&
            ![object isKindOfClass:[NSDate class]]&&
            ![object isKindOfClass:[NSData class]]&&
            ![object isKindOfClass:[NSNumber class]]) {
      NSLog(@"noncompliant object found with class: %@", [[object class] description]);

“Wow” vs. “Ofcourse”

April 6th, 2012


Too busy to make my own posts, so I’ll just link to this one by Om Malik.

The only apps I’ve found so far that are able to combine both “Wow” and “Ofcourse” are Path and Flipboard.

Buzz’D released!


The latest creation by RPBLC (design) and me has just been approved for sale in the App Store.

It’s a basic human language generator that creates random phrases filled with managerial buzzwords. We’ve put a lot of work in making this one look great, and, in my opinion, it outclasses any similar app in the Store.

Go check it out on the App Store!

Buzz'd screenshot

Sample screenshot

Welcome! To the both of us!

January 3rd, 2012


You’ve landed at my brand new home. There’s not much to see now, but if you have pressing questions or messages, you can reach me at or on Twitter @KrisAppaya.