Latest 1.0.2
Homepage https://github.com/jozsef-vesza/JVRCellConfiguratorDelegate
License MIT
Platforms ios 5.0, requires ARC
Authors

JVRCellConfiguratorDelegate Pod

A protocol for classes responsible for the creation and configuration of UICollectionViewCell or UITableViewCell objects. This class is a meant to be used with my JVRCollectionViewDataSource and JVRBaseTableViewDataSource projects

Configuring Cells

Cell configurator classes aim to encapsulate the logic that previously belonged in the tableView:cellForRowAtIndexPath:/collectionView:cellForItemAtIndexPath: method found in the UITableViewDataSource/UICollectionViewDataSource 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. The example below shows a possible implementation for table view cells, but the same process can also be used for collection view.

// MyCellConfigurator.h
#import "JVRCellConfiguratorDelegate.h"

@interface MyCellConfigurator : NSObject<JVRCellConfiguratorDelegate>
@end

// 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;
}

@end

Installation

If you are using JVRCollectionViewDataSource or JVRBaseTableViewDataSource with CocoaPods, JVRCellConfiguratorDelegate is also downloaded as a dependency. You can include it separately by adding the source files to your project or adding the project to your Podfile:

pod 'JVRCellConfiguratorDelegate'

Latest podspec

{
    "name": "JVRCellConfiguratorDelegate",
    "version": "1.0.2",
    "summary": "A protocol for classes responsible for the creation and configuration of UICollectionViewCell or UITableViewCell objects.",
    "homepage": "https://github.com/jozsef-vesza/JVRCellConfiguratorDelegate",
    "license": "MIT",
    "authors": {
        "Ju00f3zsef Vesza": "[email protected]"
    },
    "social_media_url": "http://twitter.com/j_vesza",
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/jozsef-vesza/JVRCellConfiguratorDelegate.git",
        "tag": "1.0.2"
    },
    "source_files": "*.h",
    "public_header_files": "*.h",
    "requires_arc": true
}

Pin It on Pinterest

Share This