Latest 1.0.1
License MIT
Platforms ios 6.0, requires ARC
Frameworks Foundation, UIKit

A plugin of UITableView can easy manage models and auto calculate cell height with autolayout


#import "UITableView+NJEasyTable.h"

Set up models

You can add sections and rows to nj_TableModel.

[self.tableView.nj_TableModel addSection:({
        NJEasyTableSection *section = [[NJEasyTableSection alloc] initWithModel:nil];
        [section addRow:({
            NJEasyTableRow *row = [[NJEasyTableRow alloc] initWithModel:model];
            row.cellHeight = 44;

Get models in dataSource and delegate method of UITableView

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    return [tableView.nj_TableModel numberOfSections];

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    return [tableView.nj_TableModel numberOfRowsInSection:section];

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    static NSString *identifier = @"cellIdentifier";
    TestCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[TestCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    id model = [tableView.nj_TableModel modelAtIndexPath:indexPath];
    [cell configWithModel:model];

    return cell;

Dynamic cell heights

If you use autolayout in UITableViewCell. you doesn’t need to calculate cell height manually.
Cell height value can like this:

// regist a cell for calculate cell height
TestCell *cell = [[TestCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
[self.tableView nj_registAutolayoutCell:cell forAutomaticCalculationHeightIdentifier:@"testCell"];

// implement in heightForRow
- (GFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {

    CGFloat height = [tableView nj_intrinsicHeightAtIndexPath:indexPath
                                              configCellBlock:^(TestCell *cell, id model) {
                                                  [cell configWithModel:model];
    return height;

Latest podspec

    "name": "NJEasyTable",
    "version": "1.0.1",
    "summary": "Manage Datasource of UITableView",
    "description": "help UITableView to manage datasn* Easy Manage Data Model of TableViewn* Easy calculate and cache cell height",
    "platforms": {
        "ios": "6.0"
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "u5ff5u7eaa": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.1"
    "source_files": "sources/**/*.{h,m}",
    "requires_arc": true,
    "frameworks": [

Pin It on Pinterest

Share This