The iOS framework that grows only as fast as its documentation
NITableViewActions Class Reference

Overview

The NITableViewActions class provides an interface for attaching actions to objects in a NITableViewModel.

Basic Use

NITableViewModel and NITableViewActions cooperate to solve two related tasks: data representation and user actions, respectively. A NITableViewModel is composed of objects and NITableViewActions maintains a mapping of actions to these objects. The object's attached actions are executed when the user interacts with the cell representing an object.

Delegate Forwarding

NITableViewActions will apply the correct accessoryType and selectionStyle values to the cell when the cell is displayed using a mechanism known as delegate chaining. This effect is achieved by invoking forwardingTo: on the NITableViewActions instance and providing the appropriate object to forward to (generally self).

tableView.delegate = [self.actions forwardingTo:self];

The dataSource property of the table view must be an instance of NITableViewModel.

Inheritance diagram for NITableViewActions:
NIActions

Tasks

Configurable Properties
UITableViewCellSelectionStyle tableViewCellSelectionStyle property
 
Forwarding
(id< UITableViewDelegate >) - forwardingTo:
 
(void) - removeForwarding:
 
Object State
(UITableViewCellAccessoryType) - accessoryTypeForObject:
 
(UITableViewCellSelectionStyle) - selectionStyleForObject:
 
Creating Table View Actions
(id) - initWithTarget:
 
Mapping Objects
(id) - attachToObject:tapBlock:
 
(id) - attachToObject:detailBlock:
 
(id) - attachToObject:navigationBlock:
 
(id) - attachToObject:tapSelector:
 
(id) - attachToObject:detailSelector:
 
(id) - attachToObject:navigationSelector:
 
Mapping Classes
(void) - attachToClass:tapBlock:
 
(void) - attachToClass:detailBlock:
 
(void) - attachToClass:navigationBlock:
 
(void) - attachToClass:tapSelector:
 
(void) - attachToClass:detailSelector:
 
(void) - attachToClass:navigationSelector:
 
Object State
(BOOL) - isObjectActionable:
 
(id) + objectFromKeyClass:map:
 

Method Documentation

tableViewCellSelectionStyle

The cell selection style that will be applied to the cell when it is displayed using delegate forwarding.

@property (nonatomic) UITableViewCellSelectionStyle tableViewCellSelectionStyle;
Discussion

By default this is UITableViewCellSelectionStyleBlue.

forwardingTo:

Sets the delegate that table view methods should be forwarded to.

- (id<UITableViewDelegate>)forwardingTo:(id<UITableViewDelegate>)forwardDelegate;
Discussion

This method allows you to insert the actions into the call chain for the table view's delegate methods.

Example:

// Let the actions handle delegate methods and then forward them to whatever delegate was
// already assigned.
self.tableView.delegate = [self.actions forwardingTo:self.tableView.delegate];
Parameters
forwardDelegateThe delegate to forward invocations to.
Returns
self so that this method can be chained.

removeForwarding:

Removes the delegate from the forwarding chain.

- (void)removeForwarding:(id<UITableViewDelegate>)forwardDelegate;
Discussion

If a forwared delegate is about to be released but this object may live on, you must remove the forwarding in order to avoid invalid access errors at runtime.

Parameters
forwardDelegateThe delegate to stop forwarding invocations to.

accessoryTypeForObject:

Returns the accessory type this actions object will apply to a cell for the given object when it is displayed.

- (UITableViewCellAccessoryType)accessoryTypeForObject:(id)object;
Discussion
Parameters
objectThe object to determine the accessory type for.
Returns
the accessory type this object's cell will have.

selectionStyleForObject:

Returns the cell selection style this actions object will apply to a cell for the given object when it is displayed.

- (UITableViewCellSelectionStyle)selectionStyleForObject:(id)object;
Discussion
Parameters
objectThe object to determine the selection style for.
Returns
the selection style this object's cell will have.