The iOS framework that grows only as fast as its documentation

Classes

class  NIActions
 The NIActions class provides a generic interface for attaching actions to objects. More...
 

Typedefs

typedef BOOL(^ NIActionBlock )(id object, id target, NSIndexPath *indexPath)
 

Functions

NIActionBlock NIPushControllerAction (Class controllerClass)
 

Creating Table View Actions

(id) - NIActions::initWithTarget:
 

Mapping Objects

(id) - NIActions::attachToObject:tapBlock:
 
(id) - NIActions::attachToObject:detailBlock:
 
(id) - NIActions::attachToObject:navigationBlock:
 
(id) - NIActions::attachToObject:tapSelector:
 
(id) - NIActions::attachToObject:detailSelector:
 
(id) - NIActions::attachToObject:navigationSelector:
 

Mapping Classes

(void) - NIActions::attachToClass:tapBlock:
 
(void) - NIActions::attachToClass:detailBlock:
 
(void) - NIActions::attachToClass:navigationBlock:
 
(void) - NIActions::attachToClass:tapSelector:
 
(void) - NIActions::attachToClass:detailSelector:
 
(void) - NIActions::attachToClass:navigationSelector:
 

Object State

(BOOL) - NIActions::isObjectActionable:
 
(id) + NIActions::objectFromKeyClass:map:
 

Overview

For attaching actions to objects.

Typedef Documentation

NIActionBlock

Discussion
Parameters
objectAn action was performed on this object.
targetThe target that was attached to the NIActions instance.
indexPathThe index path of the object.

Function Documentation

initWithTarget:

Initializes a newly allocated table view actions object with the given target.

- (id)initWithTarget:(id)target;
Discussion

This is the designated initializer.

The target is stored as a weak reference internally.

Parameters
targetThe target that will be provided to action blocks and on which selectors will be performed.

attachToObject:tapBlock:

Attaches a tap action to the given object.

- (id)attachToObject:(id<NSObject>)object tapBlock:(NIActionBlock)action;
Discussion

A cell with an attached tap action will have its selectionStyle set to tableViewCellSelectionStyle when the cell is displayed.

The action will be executed when the object's corresponding cell is tapped. The object argument of the block will be the object to which this action was attached. The target argument of the block will be this receiver's target.

Return NO if the tap action is used to present a modal view controller. This provides a visual reminder to the user when the modal controller is dismissed as to which cell was tapped to invoke the modal controller.

The tap action will be invoked first, followed by the navigation action if one is attached.

Parameters
objectThe object to attach the action to. This object must be contained within an NITableViewModel.
actionThe tap action block.
Returns
The object that you attached this action to.
See Also
- attachToObject:tapSelector:

attachToObject:detailBlock:

Attaches a detail action to the given object.

- (id)attachToObject:(id<NSObject>)object detailBlock:(NIActionBlock)action;
Discussion

When a cell with a detail action is displayed, its accessoryType will be set to UITableViewCellAccessoryDetailDisclosureButton.

When a cell's detail button is tapped, the detail action block will be executed. The return value of the block is ignored.

Parameters
objectThe object to attach the action to. This object must be contained within an NITableViewModel.
actionThe detail action block.
Returns
The object that you attached this action to.

attachToObject:navigationBlock:

Attaches a navigation action to the given object.

- (id)attachToObject:(id<NSObject>)object navigationBlock:(NIActionBlock)action;
Discussion

When a cell with a navigation action is displayed, its accessoryType will be set to UITableViewCellAccessoryDisclosureIndicator if there is no detail action, otherwise the detail disclosure indicator takes precedence.

When a cell with a navigation action is tapped the navigation block will be executed.

If a tap action also exists for this object then the tap action will be executed first, followed by the navigation action.

Parameters
objectThe object to attach the action to. This object must be contained within an NITableViewModel.
actionThe navigation action block.
Returns
The object that you attached this action to.

attachToObject:tapSelector:

Attaches a tap selector to the given object.

- (id)attachToObject:(id<NSObject>)object tapSelector:(SEL)selector;
Discussion

The method signature for the selector is:

- (BOOL)didTapObject:(id)object;

A cell with an attached tap action will have its selectionStyle set to tableViewCellSelectionStyle when the cell is displayed.

The selector will be performed on the action object's target when a cell with a tap selector is tapped, unless that selector does not exist on the target in which case nothing happens.

If the selector invocation returns YES then the cell will be deselected immediately after the invocation completes its execution. If NO is returned then the cell's selection will remain.

Return NO if the tap action is used to present a modal view controller. This provides a visual reminder to the user when the modal controller is dismissed as to which cell was tapped to invoke the modal controller.

The tap action will be invoked first, followed by the navigation action if one is attached.

Parameters
objectThe object to attach the selector to. This object must be contained within an NITableViewModel.
selectorThe selector that will be invoked by this action.
Returns
The object that you attached this action to.
See Also
- attachToObject:tapBlock:

attachToObject:detailSelector:

Attaches a detail selector to the given object.

- (id)attachToObject:(id<NSObject>)object detailSelector:(SEL)selector;
Discussion

The method signature for the selector is:

- (void)didTapObject:(id)object;

A cell with an attached tap action will have its selectionStyle set to tableViewCellSelectionStyle and its accessoryType set to UITableViewCellAccessoryDetailDisclosureButton when the cell is displayed.

The selector will be performed on the action object's target when a cell with a detail selector's accessory indicator is tapped, unless that selector does not exist on the target in which case nothing happens.

Parameters
objectThe object to attach the selector to. This object must be contained within an NITableViewModel.
selectorThe selector that will be invoked by this action.
Returns
The object that you attached this action to.
See Also
- attachToObject:detailBlock:

attachToObject:navigationSelector:

Attaches a navigation selector to the given object.

- (id)attachToObject:(id<NSObject>)object navigationSelector:(SEL)selector;
Discussion

The method signature for the selector is:

- (void)didTapObject:(id)object;

A cell with an attached navigation action will have its selectionStyle set to tableViewCellSelectionStyle and its accessoryType set to UITableViewCellAccessoryDetailDisclosureButton, unless it also has an attached detail action, in which case its accessoryType will be set to UITableViewCellAccessoryDisclosureIndicator when the cell is displayed.

The selector will be performed on the action object's target when a cell with a navigation selector is tapped, unless that selector does not exist on the target in which case nothing happens.

Parameters
objectThe object to attach the selector to. This object must be contained within an NITableViewModel.
selectorThe selector that will be invoked by this action.
Returns
The object that you attached this action to.
See Also
- attachToObject:navigationBlock:

attachToClass:tapBlock:

Attaches a tap block to a class.

- (void)attachToClass:(Class)aClass tapBlock:(NIActionBlock)action;
Discussion

This method behaves similarly to attachToObject:tapBlock: except it attaches a tap action to all instances and subclassed instances of a given class.

Parameters
aClassThe class to attach the action to.
actionThe tap action block.

attachToClass:detailBlock:

Attaches a detail block to a class.

- (void)attachToClass:(Class)aClass detailBlock:(NIActionBlock)action;
Discussion

This method behaves similarly to attachToObject:detailBlock: except it attaches a detail action to all instances and subclassed instances of a given class.

Parameters
aClassThe class to attach the action to.
actionThe detail action block.

attachToClass:navigationBlock:

Attaches a navigation block to a class.

- (void)attachToClass:(Class)aClass navigationBlock:(NIActionBlock)action;
Discussion

This method behaves similarly to attachToObject:navigationBlock: except it attaches a navigation action to all instances and subclassed instances of a given class.

Parameters
aClassThe class to attach the action to.
actionThe navigation action block.

attachToClass:tapSelector:

Attaches a tap selector to a class.

- (void)attachToClass:(Class)aClass tapSelector:(SEL)selector;
Discussion

This method behaves similarly to attachToObject:tapBlock: except it attaches a tap action to all instances and subclassed instances of a given class.

Parameters
aClassThe class to attach the action to.
selectorThe tap selector.

attachToClass:detailSelector:

Attaches a detail selector to a class.

- (void)attachToClass:(Class)aClass detailSelector:(SEL)selector;
Discussion

This method behaves similarly to attachToObject:detailBlock: except it attaches a detail action to all instances and subclassed instances of a given class.

Parameters
aClassThe class to attach the action to.
selectorThe tap selector.

attachToClass:navigationSelector:

Attaches a navigation selector to a class.

- (void)attachToClass:(Class)aClass navigationSelector:(SEL)selector;
Discussion

This method behaves similarly to attachToObject:navigationBlock: except it attaches a navigation action to all instances and subclassed instances of a given class.

Parameters
aClassThe class to attach the action to.
selectorThe tap selector.

isObjectActionable:

Returns whether or not the object has any actions attached to it.

- (BOOL)isObjectActionable:(id<NSObject>)object;

objectFromKeyClass:map:

Returns a mapped object from the given key class.

+ (id)objectFromKeyClass:(Class)keyClass map:(NSMutableDictionary *)map;
Discussion

If the key class is a subclass of any mapped key classes, the nearest ancestor class's mapped object will be returned and keyClass will be added to the map for future accesses.

Parameters
keyClassThe key class that will be used to find the mapping in map.
mapA map of key classes to classes. May be modified if keyClass is a subclass of any existing key classes.
Returns
The mapped object if a match for keyClass was found in map. nil is returned otherwise.

NIPushControllerAction

Returns a block that pushes an instance of the controllerClass onto the navigation stack.

NIActionBlock NIPushControllerAction:(Class)controllerClass;
Discussion

Allocates an instance of the controller class and calls the init selector.

The target property of the NIActions instance must be an instance of UIViewController with an attached navigationController.

Parameters
controllerClassThe class of controller to instantiate.