Sensible TableView

I recently had an opportunity to spend some time working with Sensible Tableview, a product from

Let me take you through a few of the first steps in the video to give you a feel for Sensible TableView. The introduction begins by creating a simple grouped table and adding four cells, a textfield, slider, switch and a selection list. The code follows:

NSArray *selectionItems = [NSArray arrayWithObjects:@"Song 1", @"Song 2", nil];
scTableView = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
SCTableViewSection *section = [SCTableViewSection sectionWithHeaderTitle:@"Music Profile"];
[scTableView addSection:section];
[section addCell:[SCTextFieldCell cellWithText:@"Name"]];
[section addCell:[SCSliderCell cellWithText:@"Volume Level"]];
[section addCell:[SCSwitchCell cellWithText:@"Sharing Enabled"]];
SCSelectionCell *selectionCell = [SCSelectionCell cellWithText:@"Favorite Song"];
selectionCell.items = selectionItems;
[section addCell:selectionCell];

The tableview is shown in the figure below:

If you’ve worked with a tableview, delegates and creating custom cells, you can appreciate all the functionality provided in about 10 lines of code.

Detect Table Cell Changes

Let’s look at how to bind cells to instance variables in an object. The example shown in the video uses a class that looks as follows:

@interface Task : NSObject 
  NSString	*name;
  NSString	*description;
  NSDate		*dueDate;
  NSNumber	*active;
  NSNumber	*priority;
  NSNumber	*categoryIndex;
  NSMutableArray *steps;

The code to bind a Task object variables to fields in a table view is below, notice the reference to withBoundObject:

NSArray *selectionItems = [NSArray arrayWithObjects:@"Office", @"Home", nil];
taskObject = [[Task alloc] init];
[taskObject setName:@"Task"];
scTableView = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
SCTableViewSection *section = [SCTableViewSection sectionWithHeaderTitle:@"Music Profile"];
[scTableView addSection:section];
[section addCell:[SCTextFieldCell cellWithText:@"Name" withPlaceholder:@"Enter name" withBoundObject:taskObject  withTextFieldTextPropertyName:@"name"]];
[section addCell:[SCTextViewCell cellWithText:@"Description" withBoundObject:taskObject withTextViewTextPropertyName:@"description"]];
[section addCell:[SCDateCell cellWithText:@"Due Date" withBoundObject:taskObject withDatePropertyName:@"dueDate"]];
[section addCell:[SCSwitchCell cellWithText:@"Active" withBoundObject:taskObject withSwitchOnPropertyName:@"active"]];
SCSliderCell *priorityCell = [SCSliderCell cellWithText:@"Priority" withBoundObject:taskObject withSliderValuePropertyName:@"priority"];
[section addCell:priorityCell];
[section addCell:[SCSelectionCell cellWithText:@"Category" withBoundObject:taskObject 
               withSelectedIndexesPropertyName:@"categoryIndex" withItems:selectionItems allowMultipleSelection:NO]];

With the bound object, you can now watch the values of each table row change in the debugging console, all that is required is to add a delegate method to the current class and implement a method to be called when table data changes.

The method called upon changing table cells is shown below:

- (void) tableViewModel:(SCTableViewModel *) tableViewModel valueChangedForRowAtIndexPath:(NSIndexPath *)indexPath
  [taskObject logTask];

And inside the task class, the log function is equally as short:

- (void)logTask
  NSLog(@"\n\nname:%@, description:%@, dueDate:%@, active:%@, priority:%@, categoryIndex:%@",
        name, description, dueDate, active, priority, categoryIndex);

The figure below shows the current application and the table fields listed above:

Below is the Due Date field, followed by the output shown in the console when the content of the Due Date field changes:

Other Features

The examples above should give you an idea of how quickly you can get things working with Sensible TableView, with minimal coding. There are a range of features to simplify your life when working with tables, a few highlights are listed below:

– Custom and predefined cell validation
– Support for Core Data (check out the Core Data video)
– Create custom cells from within Interface Builder
– iOS 5.0 suport including automatic reference counting
– Full source code

Take a Closer Look

One of the best ways to see Sensible TableView in action is check out the video tutorials:

Sensible Tableview Video Tutorials

If you work with anything beyond the simplest of tableviews, you owe it to yourself to take a closer look.

  1. Great overview of STV. One important feature that you left out though is the amazing level of support provided by the STV developers. They respond quickly in the STV forum, and will even help at the code level – especially for newbies.

    It’s a company and product that are really user-driven.

Comments are closed.