Coder Social home page Coder Social logo

jozsef-vesza / jvrcellconfiguratordelegate Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 160 KB

A protocol for classes responsible for the creation and configuration of UICollectionViewCell or UITableViewCell objects.

License: MIT License

Objective-C 57.99% Ruby 42.01%

jvrcellconfiguratordelegate's Introduction

##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'

jvrcellconfiguratordelegate's People

Contributors

jozsef-vesza avatar

Stargazers

Indrajit Chakrabarty avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.