Giter Site home page Giter Site logo

matteocrippa / uitableviewcellmanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from corlaonline/uitableviewcellmanager

0.0 3.0 0.0 40 KB

UITableViewCellManager is a collection of usefull functions for manage your UITableViewCells in your projects.

License: MIT License

Ruby 7.26% Objective-C 3.53% Shell 58.95% Swift 30.26%

uitableviewcellmanager's Introduction

UITableViewCellManager

[![CI Status](http://img.shields.io/travis/Alex Corlatti/UITableViewCellManager.svg?style=flat)](https://travis-ci.org/Alex Corlatti/UITableViewCellManager) Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build UITableViewCellManager

To integrate UITableViewCellManager into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'UITableViewCellManager'

Then, run the following command:

$ pod install

Usage

You have to create an enum that conform UITableViewCellStructureDataSource, variable cellStructure is mandatory.

cellStructure is a variable of type UITableViewCellStructure, a struct with these parameters:

  • type: UITableViewCell the type of your cell
  • identifier: String the reusable identifier setted in Interface builder
  • nib: String? the nib name if the cell is loaded from a .xib file, by default is nil

Create your cell manager

import UITableViewCellManager

enum MyCellType: UITableViewCellStructureDataSource {

    case simpleCell
    case nibCell

    var cellStructure: UITableViewCellStructure {

        switch self {

        case .simpleCell:
            return UITableViewCellStructure(type: UITableViewCell(), identifier: "SimpleCell")

        case .nibCell:
            return UITableViewCellStructure(type: NibTableViewCell(), identifier: "NibCell", nib: "NibTableViewCell")

        }

    }

}

Use it in your table

The library add some methods to UITableView and UITableViewCell.

In UITableView now you can create a cell and use it with

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

 	let myCell = tableView.createCell(cellType: UITableViewCellStructureDataSource)

	//...do something with the cell

	return myCell

}

or setting directly the UI with

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

 	return tableView.setUICell(cellType: UITableViewCellStructureDataSource, object: Anyobject)

}

To use it, your cell must to override the new UITableViewCell method setUI(object: AnyObject) like this way

override func setUI(object: AnyObject?) {
        
	guard let text = object as? String else { return }
     
	myCellLabel.text = text
        
}

Author

Alex Corlatti, [email protected]

License

UITableViewCellManager is available under the MIT license. See the LICENSE file for more info.

uitableviewcellmanager's People

Contributors

corlaonline avatar cjennewein-uhi avatar matteocrippa avatar

Watchers

 avatar James Cloos avatar  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.