I have a new open-source library on Github for use by iOS developers: KJMenuTableViewController.
KJMenuTableViewController is an Xcode project that contains set of classes that simplifies the
creation of "menus" in iOS applications using
UITableViewController class is a generic mechanism for presenting a scrollable list of
rows of items. It is powerful and extensible, but it can be a chore to present a simple
list of button-like objects that react when tapped. One must provide implementations of several
methods of the
UITableViewDelegate classes, each of which will
probably have a
case statement to handle each of the individual items. It's not difficult, but it is
tedious and error-prone.
The KJMenuTableViewController classes simplify this usage case. One simply defines a subclass of
KJMenuTableViewController and overrides the
viewDidLoad method to create sections and row items.
KJMenuTableViewController implements the table view delegate and data source methods to
appropriately display the sections and rows, and will take action when a row is tapped.
The code to be executed when an item is tapped are written as a block.
When the block is invoked, a
KJMenuItemInvocation structure is passed to it. This structure
contains pointers to the menu item, cell, and controller, so there is no reason for the block
to retain any of these objects itself. (Beware of retain cycles if the block does reference
the menu item, cell, or controller.)