Latest 1.0
License MIT
Platforms ios 9.0

Peppa Build Status Carthage compatible Version License Platform

Peppa is a very lightweight Swfit Framework that uses POP (Protocol-Oriented-Programming) to help you build any list views.


  • [X] Written in Swift
  • [X] Both support UITableView And UICollectionView
  • [x] POP
  • [X] Data-Driven
  • [X] Extendable API


  • Xcode 9.0+
  • iOS 9.0+
  • Swift 4.0+


Note: Peppa doesn’t work on performance. It’s goal is simply to help you build structured lists. Of course, using Peppa is very simple, and it will not destroy your code structure.

In the class that you need to build a list, implement the Peppable protocol, e.g:

Here we only introduce the use of UITableView, and the use of UICollectionView is basically the same

extension YourAwesomeViewController: Peppable, UITableViewDelegate, UITableViewDataSource {
    var peppaStories: [CellModelProtocol] {
        return [yourAwsomeModels]

use the funcs Peppa provides you with a very easy way to implement DataSource/Delegate, e.g:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return ps.tableView(tableView, numberOfRowsInSection: section)
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    return ps.tableView(tableView, cellForRowAt: indexPath)

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return ps.tableView(tableView, heightForRowAt: indexPath)

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if let model = ps.cellModel(at: indexPath) as? AwsomeModel {

This is the whole work of the list class. Finally, we just need to implement some data and views, e.g:

private struct AwesomeModel: CellModelProtocol {

    var viewSize: ViewSize {
        return .schemeSize({ (containerSize) -> CGSize in
            return CGSize(width: containerSize.width, height: 44)
    var viewType: ViewType {
        return .viewClass(AwesomeCell.self)
private class AwesomeCell: UITableViewCell, Cellable {
    func didSet(cellModel: CellModelProtocol) {
        if let awsomeModel = cellModel as? AwesomeModel {
        // Do something here

Peppa also provide an adapter PeppaAdapter, e.g:

private lazy var _adapter = PeppaAdapter.init(tableView: self.tableView)

    .dataSource { (_) -> [SectionModelProtocol] in
        let cellModels = Array(0...10).map({ _ in CellModel()})
        return []
    .configCell { (indexPath, model, cell) in

    .didSelectItem({ (indexPath) in

    .didSelectModel { (model) in




Peppa is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'Peppa'


For Carthage, add the following to your Cartfile:

github "wleii/Peppa"


Lei Wang, [email protected]


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

Latest podspec

    "name": "Peppa",
    "version": "1.0",
    "summary": "Peppa is a very lightweight Swfit Framework that uses POP (Protocol-Oriented-Programming) to help you build any list views.",
    "description": "Peppa is a very lightweight Swfit Framework that uses POP (Protocol-Oriented-Programming) to help you build any list views.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Lei Wang": "[email protected]"
    "platforms": {
        "ios": "9.0"
    "source": {
        "git": "",
        "tag": "1.0"
    "source_files": "Peppa/*",
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This