Skip to content

carabina/GPJDataDrivenTableView

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPJDataDrivenTableView

Description

GPJDataDrivenTableView is a data-driven way to use UITableView. It is easy to use. It is friendly to evolve with change of requirements.

Installation

CocoaPods

pod 'GPJDataDrivenTableView'

Manual

  1. download the GPJDataDrivenTableView repository
  2. copy the GPJDataDrivenTableView sub-folder into your Xcode project

Example

GPJDataDrivenTableViewExample

Origin

The traditional way is index-driven, we implement the UITableViewDataSource's or UITableViewDelegate's methods base on indexPath:

  • -tableView:cellForRowAtIndexPath:
  • -tableView:heightForRowAtIndexPath:
  • -tableView:didSelectRowAtIndexPath:

This index-driven way based on indexPath results a lot of if-else code segments, Various cells' code mix together. it is error-prone, hard to evolve with change of requirements.

The core role of data-driven way to use UITableView is GPJDataDrivenTableView class. GPJDataDrivenTableView contains UITableView instance and a dataArray, GPJDataDrivenTableView set itself as UITableView's dataSource and delegate, implement the protocol methods, and covert indexPath to data in dataArray. Finally we can render cell ui and respond to row selection based on data.

This data-driven way is simple, easy to implement each kind of data, cell, and select action separately.

About

The data-driven way to use UITableView

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 90.1%
  • Ruby 9.9%