Inherits from RKObjectMapping : RKObjectMappingDefinition : NSObject
Declared in RKTableViewCellMapping.h
RKTableViewCellMapping.m

Overview

Defines a RestKit object mapping suitable for mapping generic objects into UITableViewCell derived classes or cells loaded from NIBs. The cell mapping leverages RestKit’s object mapping engine to dynamically map keyPaths in your object model into properties on the table cell view.

Cell mappings are used to drive table view cells within an RKTableController derived class. The cell mapping does not require any specific implementation on the target cell classes beyond exposure of the configurable UIView’s via KVC properties.

Tasks

Other Methods

  •   cellClass

    The UITableViewCell subclass that this mapping will target. This is an alias for the objectClass property defined on the base mapping provided here to make things more explicit.

    property
  •   cellClassName

    Convenience accessor for setting the cellClass attribute via a string rather than a class instance. This will typically save you from having to #import the header file for your target cells in your table view controller

    property
  •   reuseIdentifier

    A reuse identifier for cells created using this mapping. These cells will be dequeued and reused within the table view for optimal performance. By default, a reuseIdentifier is set for you when you assign an object class to the mapping. You can override this behavior if you have multiple cells representing the same types of objects within the table view and need to pool the cells differently.

    property
  •   managesCellAttributes

    A Boolean value that determines whether the cell mapping manages basic cell attributes (accessoryType, selectionStyle, etc.) or defers to a Storyboard/XIB for defining basic cell attributes.

    property
  •   style

    The cell style to use for cells created with this mapping

    property
  •   accessoryType

    The cell accessory type to use for cells created with this mapping

    property
  •   selectionStyle

    The cell selection style to use for cells created with this mapping

    property
  •   deselectsRowOnSelection

    Whether the tableController should call deselectRowAtIndexPath:animated: on the tableView when a cell is selected.

    property
  •   rowHeight

    The row height to use for cells created with this mapping. Use of this property requires that RKTableController instance you are using the mapping to build cells for has been configured with variableHeightRows = YES

    property

Cell Events *

  •   onSelectCellForObjectAtIndexPath

    Invoked when the user has touched a cell corresponding to an object. The block is invoked with a reference to both the UITableViewCell that was touched and the object the cell is representing.

    property
  •   onSelectCell

    Invoked when the user has touched a cell configured with this mapping. The block is invoked without any arguments. This is useful for one-off touch events where you do not care about the content in which the selection took place.

    property
  •   onCellWillAppearForObjectAtIndexPath

    A block to invoke when a table view cell created with this mapping is going to appear in the table. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

    property
  •   heightOfCellForObjectAtIndexPath

    A block to invoke when the table view is measuring the height of the UITableViewCell. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

    property
  •   onTapAccessoryButtonForObjectAtIndexPath

    A block to invoke when the accessory button for a given cell is tapped by the user. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

    property
  •   titleForDeleteButtonForObjectAtIndexPath

    A block to invoke when the table view is determining the title for the delete confirmation button. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

    property
  •   editingStyleForObjectAtIndexPath

    A block to invoke when the table view is determining the editing style for a given row. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

    property
  • + cellMapping

    Returns a new auto-released mapping targeting UITableViewCell

  • + cellMappingForReuseIdentifier:

    Returns a new auto-released mapping targeting UITableViewCell with the specified reuseIdentifier

  • + defaultCellMapping

    Creates and returns an RKTableCellMapping instance configured with the default cell mappings.

  • + cellMappingUsingBlock:

    Returns a new auto-released object mapping targeting UITableViewCell. The mapping will be yielded to the block for configuration.

  • – addDefaultMappings

    Sets up default mappings connecting common properties to their UITableViewCell counterparts as follows:

  • – addPrepareCellBlock:

    Configure a block to be invoked whenever a cell is prepared for use with this mapping. The block will be invoked each time a cell is either initialized or dequeued for reuse.

Other Methods

  • – mappableObjectForData:

    Returns an auto-released object that can be used to apply this object mapping given a set of mappable data. For transient objects, this generally returns an instance of the objectClass. For Core Data backed persistent objects, mappableData will be inspected to search for primary key data to lookup existing object instances.

  • – setObjectClass:

    The target class this object mapping is defining rules for

Properties

accessoryType

The cell accessory type to use for cells created with this mapping

@property (nonatomic, assign) UITableViewCellAccessoryType accessoryType

Discussion

@default UITableViewCellAccessoryNone

Declared In

RKTableViewCellMapping.h

cellClass

The UITableViewCell subclass that this mapping will target. This is an alias for the objectClass property defined on the base mapping provided here to make things more explicit.

@property (nonatomic, assign) Class cellClass

Discussion

@default [GGImageButtonTableViewCell class]

Declared In

RKTableViewCellMapping.h

cellClassName

Convenience accessor for setting the cellClass attribute via a string rather than a class instance. This will typically save you from having to #import the header file for your target cells in your table view controller

@property (nonatomic, assign) NSString *cellClassName

Discussion

@default @“GGImageButtonTableViewCell”

Declared In

RKTableViewCellMapping.h

deselectsRowOnSelection

Whether the tableController should call deselectRowAtIndexPath:animated: on the tableView when a cell is selected.

@property (nonatomic, assign) BOOL deselectsRowOnSelection

Discussion

@default YES

Declared In

RKTableViewCellMapping.h

editingStyleForObjectAtIndexPath

A block to invoke when the table view is determining the editing style for a given row. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

@property (nonatomic, copy) RKTableViewEditingStyleForObjectAtIndexPathBlock editingStyleForObjectAtIndexPath

Declared In

RKTableViewCellMapping.h

heightOfCellForObjectAtIndexPath

A block to invoke when the table view is measuring the height of the UITableViewCell. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

@property (nonatomic, copy) RKTableViewHeightOfCellForObjectAtIndexPathBlock heightOfCellForObjectAtIndexPath

Declared In

RKTableViewCellMapping.h

managesCellAttributes

A Boolean value that determines whether the cell mapping manages basic cell attributes (accessoryType, selectionStyle, etc.) or defers to a Storyboard/XIB for defining basic cell attributes.

@property (nonatomic, assign) BOOL managesCellAttributes

Discussion

Setting the accessoryType or selectionStyle will set the value to YES.

Default: NO

Declared In

RKTableViewCellMapping.h

onCellWillAppearForObjectAtIndexPath

A block to invoke when a table view cell created with this mapping is going to appear in the table. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

@property (nonatomic, copy) RKTableViewCellForObjectAtIndexPathBlock onCellWillAppearForObjectAtIndexPath

Discussion

This is a good moment to perform any customization to the cell before it becomes visible in the table view.

Declared In

RKTableViewCellMapping.h

onSelectCell

Invoked when the user has touched a cell configured with this mapping. The block is invoked without any arguments. This is useful for one-off touch events where you do not care about the content in which the selection took place.

@property (nonatomic, copy) RKTableViewAnonymousBlock onSelectCell

Declared In

RKTableViewCellMapping.h

onSelectCellForObjectAtIndexPath

Invoked when the user has touched a cell corresponding to an object. The block is invoked with a reference to both the UITableViewCell that was touched and the object the cell is representing.

@property (nonatomic, copy) RKTableViewCellForObjectAtIndexPathBlock onSelectCellForObjectAtIndexPath

Declared In

RKTableViewCellMapping.h

onTapAccessoryButtonForObjectAtIndexPath

A block to invoke when the accessory button for a given cell is tapped by the user. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

@property (nonatomic, copy) RKTableViewAccessoryButtonTappedForObjectAtIndexPathBlock onTapAccessoryButtonForObjectAtIndexPath

Declared In

RKTableViewCellMapping.h

reuseIdentifier

A reuse identifier for cells created using this mapping. These cells will be dequeued and reused within the table view for optimal performance. By default, a reuseIdentifier is set for you when you assign an object class to the mapping. You can override this behavior if you have multiple cells representing the same types of objects within the table view and need to pool the cells differently.

@property (nonatomic, retain) NSString *reuseIdentifier

Discussion

@default NSStringFromClass(self.objectClass)

Declared In

RKTableViewCellMapping.h

rowHeight

The row height to use for cells created with this mapping. Use of this property requires that RKTableController instance you are using the mapping to build cells for has been configured with variableHeightRows = YES

@property (nonatomic, assign) CGFloat rowHeight

Discussion

This value is mutually exclusive of the heightOfCellForObjectAtIndexPath property and will be ignored if you assign a block to perform dynamic row height calculations.

Default: 44

Declared In

RKTableViewCellMapping.h

selectionStyle

The cell selection style to use for cells created with this mapping

@property (nonatomic, assign) UITableViewCellSelectionStyle selectionStyle

Discussion

@default UITableViewCellSelectionStyleBlue

Declared In

RKTableViewCellMapping.h

style

The cell style to use for cells created with this mapping

@property (nonatomic, assign) UITableViewCellStyle style

Discussion

@default UITableViewCellStyleDefault

Declared In

RKTableViewCellMapping.h

titleForDeleteButtonForObjectAtIndexPath

A block to invoke when the table view is determining the title for the delete confirmation button. The block will be invoked with the UITableViewCell, an id reference to the mapped object being represented in the cell, and the NSIndexPath for the row position the cell will be appearing at.

@property (nonatomic, copy) RKTableViewTitleForDeleteButtonForObjectAtIndexPathBlock titleForDeleteButtonForObjectAtIndexPath

Declared In

RKTableViewCellMapping.h

Class Methods

cellMapping

Returns a new auto-released mapping targeting UITableViewCell

+ (id)cellMapping

Declared In

RKTableViewCellMapping.h

cellMappingForReuseIdentifier:

Returns a new auto-released mapping targeting UITableViewCell with the specified reuseIdentifier

+ (id)cellMappingForReuseIdentifier:(NSString *)reuseIdentifier

Declared In

RKTableViewCellMapping.h

cellMappingUsingBlock:

Returns a new auto-released object mapping targeting UITableViewCell. The mapping will be yielded to the block for configuration.

+ (id)cellMappingUsingBlock:(void ( ^ ) ( RKTableViewCellMapping *cellMapping ))block

Declared In

RKTableViewCellMapping.h

defaultCellMapping

Creates and returns an RKTableCellMapping instance configured with the default cell mappings.

+ (id)defaultCellMapping

Return Value

An RKTableCellMapping instance with default mappings applied.

Declared In

RKTableViewCellMapping.h

Instance Methods

addDefaultMappings

Sets up default mappings connecting common properties to their UITableViewCell counterparts as follows:

- (void)addDefaultMappings

Discussion

 [self mapKeyPath:@"text" toAttribute:@"textLabel.text"];
 [self mapKeyPath:@"detailText" toAttribute:@"detailTextLabel.text"];
 [self mapKeyPath:@"image" toAttribute:@"imageView.image"];

These properties are exposed on the RKTableItem class for convenience in quickly building static table views/

See Also

Declared In

RKTableViewCellMapping.h

addPrepareCellBlock:

Configure a block to be invoked whenever a cell is prepared for use with this mapping. The block will be invoked each time a cell is either initialized or dequeued for reuse.

- (void)addPrepareCellBlock:(void ( ^ ) ( UITableViewCell *cell ))block

Declared In

RKTableViewCellMapping.h

mappableObjectForData:

Returns an auto-released object that can be used to apply this object mapping given a set of mappable data. For transient objects, this generally returns an instance of the objectClass. For Core Data backed persistent objects, mappableData will be inspected to search for primary key data to lookup existing object instances.

- (id)mappableObjectForData:(UITableView *)tableView

Declared In

RKObjectMapping.h

setObjectClass:

The target class this object mapping is defining rules for

- (void)setObjectClass:(Class)objectClass

Declared In

RKObjectMapping.h