EasyTableView for iPhone Prototyping

Our first blog post of 2010 presents a tool that we’ve been using internally and that might be useful for other people.

As you might have experienced, prototyping applications in Interface Builder is fine as long as you don’t deal that much with UITableViewController instances. Prototyping user interfaces with tables and navigation is not as easy as drag-and-dropping some components, and you usually have to implement a small UITableViewController subclass from scratch yourself, including some kind of navigation logic.

Enter EasyTableView, a set of classes inheriting from UINavigationController and UITableViewController, ready to use in your own projects, to quickly simulate interfaces using navigation and tables. I’ve been using this code in several prototypes, and it allows me to quickly craft navigation-based applications loading several different tables. The AKOEasyTableViewControllerDelegate protocol allows other classes to be notified of taps on cells or on accessory buttons.

The code is available, as usual, in Github with a liberal BSD license.

The code snippets below show how to use the classes:

NSArray *data = [NSArray arrayWithObjects:@"first", @"second", @"third", nil];

AKOEasyTableViewController *controller = nil;
controller = [[AKOEasyTableViewController alloc] initWithStyle:UITableViewStylePlain];
controller.title = @"Easy Table View";
controller.delegate = self; // AKOEasyTableViewControllerDelegate...
controller.dataSource = data;
controller.autoDeselect = YES;
controller.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
_navigationController = [[AKOEasyNavigationController alloc] initWithRootViewController:controller];
_navigationController.dataSequenceFileName = @"Sequence";

With the code above, the freshly created AKOEasyNavigationController will load the file “Sequence.plist”, which itself references other plist files in your project.

Data can be loaded in code (as NSArray or NSDictionary instances) or using external plist files, through the dataSourceFileName property of the AKOEasyTableViewController class. The formats of the data in the plist files is the simplest you could imagine:

<?xml version="1.0" encoding="UTF-8"??>

<plist version="1.0">
	<string>Roger Federer</string>
	<string>Rafael Nadal</string>
	<string>Novak Djokovic</string>
	<string>Andy Murray</string>
	<string>Juan Martin Del Potro</string>
	<string>Andy Roddick</string>
	<string>Nicolay Davydenko</string>
	<string>Fernando Verdasco</string>
	<string>Robin Soderling</string>
	<string>Jo-Wilfred Tsonga</string>
	<string>Fernando González</string>
	<string>Radek Stepanek</string>
	<string>Gael Monfils</string>
	<string>Marin Cilic</string>
	<string>Gilles Simon</string>

The plist files can also be NSDictionary instances, with a “title” NSString key, and a “values” key of type NSArray; in this case, the controller is shown with several different groups. AKOEasyNavigationController requires the AKOEasyTableViewController class, but you can use this last one independently as well.

Feel free to clone the project, use it in your own projects and send me any feedback you might have. Enjoy!