Tip: use Property List Editor to view data structures

Sometimes when I’m working with nested arrays and dictionaries — as a result of parsing some XML, for instance — I don’t even try to keep a map of the structure in my head.

Instead I write the dictionary or array out to a file...

[someObject writeToFile:@"/Users/brent/Desktop/foo.plist" atomically:YES];

...and open it with Property List Editor, so I can actually see the structure. (This also lets me know that the structure I created is the structure I intended.)

Property List Editor screenshot

Bonus tip: valueForKeyPath can be super-handy for getting data out of nested structures.

03 Dec 2008

Archive