Latest 0.0.7
License MIT
Platforms ios 5.0, requires ARC

JVRBaseTableViewDataSource Build Status

A basic, reusable and expandable UITableViewDataSource class, to take the clutter out of your UITableView classes. To use it, you will also need a class that conforms to the JVRCellConfiguratorDelegate, which will setup the individual cells, for the table view. For details about the usage, see the simple examples below, or refer to the example project.

Configuring Table View Cells

Cell configurator classes aim to encapsulate the logic that previously belonged in the tableView:cellForRowAtIndexPath: method found in the UITableViewDataSource protocol. They can be used to return the reuse identifier for a cell according to the object it is supposed to show, and to customize its appearance or behavior.

// MyCellConfigurator.h
#import "JVRBaseTableViewDataSource.h"

@interface MyCellConfigurator : NSObject<JVRCellConfiguratorDelegate>

// MyCellConfigurator.m
@implementation MyCellConfigurator

- (NSString *)fetchCellIdentifierForObject:(id)anObject
    if ([anObject isKindOfClass:[MyClass class]])
        return @"myCell";

    return @"regularCell";

- (UITableViewCell *)configureCell:(MyCell *)cell usingObject:(MyClass *)object
    cell.titleLabel.text = object.stringProperty;
    return cell;


Example usage in a Table View Controller:

By using JVRBaseTableViewDataSource, many lines of boilerplate code can be omitted from UITableViewController classes. Support for table view sections can be achieved by sublassing or editing this class, and implementing the numberOfSectionsInTableView: method.

// MyTableViewController.m
#import "JVRBaseTableViewDataSource.h"
#import "MyCellConfigurator.h"

@interface MyTableViewController ()

@property (nonatomic, strong) JVRBaseTableViewDataSource *dataSource;


@implementation MyTableViewController

- (void)viewDidLoad
    [super viewDidLoad];
    [self setupDataSource];

- (void)setupDataSource
    self.dataSource = [JVRBaseTableViewDatasource datasourceForTableView:self.tableView
                                                               withItems:@[@"test", @"item"]
                                                   usingCellConfigurator:[[MyCellConfigurator alloc] init]];



You can just copy the source files into your project, but the recommended way of using this class in your project is installation through CocoaPods with the following Podfile:

platform :ios, "7.1"

pod 'JVRBaseTableViewDataSource'

Latest podspec

    "name": "JVRBaseTableViewDataSource",
    "version": "0.0.7",
    "summary": "A basic, reusable and expandable UITableViewDataSource class",
    "homepage": "",
    "license": {
        "type": "MIT"
    "authors": {
        "Ju00f3zsef Vesza": "[email protected]"
    "social_media_url": "",
    "source": {
        "git": "",
        "tag": "0.0.7"
    "platforms": {
        "ios": "5.0"
    "source_files": "*.{h,m}",
    "public_header_files": "*.h",
    "exclude_files": "Lighter Table View/*",
    "requires_arc": true

Pin It on Pinterest

Share This