GenericTableViewController - An example to use of generics with UITableViewController

Overview

GenericTableView

An example to use of generics with UITableViewController. With help of GenericListViewController.swift and BaseTableViewCell.swift, data can be populated without worrying about cell registration and TableView DataSource methods.

HOW TO USE

  • Drag- Drop 'GenericListViewController.swift' and 'BaseTableViewCell.swift' file into your project folder.
  • Create your data model say ModelRoot.
  • Create a subclass of GenericListViewController say RootViewController.
  • Create subclass of BaseTableViewCell say RootTableViewCell.

Your custom cell code will be as below

  class RootTableViewCell: BaseTableViewCell<ModelRoot> {
        fileprivate let padding_constant: CGFloat = 10.0
       //Just to customize table cell and to explain use of custom cell
       var labelName: UILabel!
       
     override var item: ModelRoot! {
       didSet {
           self.labelName.text = item.name
       }
    }
  }

Your ViewController will be as below

class RootViewController: GenericListViewController<RootTableViewCell, ModelRoot> {
 .......
}

Inside your view controler file's viewdidLoad, supply data

 class RootViewController: GenericListViewController<RootTableViewCell, ModelRoot> {
  let dummyNames = [ModelRoot(name: "James"), ModelRoot(name: "Bianca"), ModelRoot(name: "Robert"), ModelRoot(name: "Peter"), ModelRoot(name: "Gagan"), ModelRoot(name: "Siree"), ModelRoot(name: "Sarah"), ModelRoot(name: "Pure"),  ModelRoot(name: "Annu"),  ModelRoot(name: "Const")]

  //MARK:- View Controller life cyle
  override func viewDidLoad() {
      super.viewDidLoad()
      //title
      self.title = "Generic Table"
      items = dummyNames
  }

ModelRoot

  struct ModelRoot {
   let name: String
}
You might also like...
Assignment 2 - A fully functional example in the CardinalKit-Example directory
Assignment 2 - A fully functional example in the CardinalKit-Example directory

Assignment 2 - A fully functional example in the CardinalKit-Example directory

IBCalculator is an example app to demonstrate how to use @IBDesignable and @IBInspectable
IBCalculator is an example app to demonstrate how to use @IBDesignable and @IBInspectable

IBCalculator IBCalculator is an example app to demonstrate how to use @IBDesignable and @IBInspectable. The origin code is from IBInspectable / IBDesi

An example project showing how to use `overrideUserInterfaceStyle` to build an in-app light/dark mode switch

OverrideDarkMode A sample project to show how using overrideUserInterfaceStyle enables having a dark / light mode switch directly in the app, while st

Example project showing how to use async/await with iOS 13
Example project showing how to use async/await with iOS 13

ios13AsyncAwait Example project showing how to use async/await with iOS 13 Article This source code is a part of an article published at This Dev Brai

Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.
Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.

SPDiffable Apple's diffable API requerid models for each object type. If you want use it in many place, you pass many time to implemenet and get over

Realm RxSwift - This application was written in order to use Realm, RxSwift frameworks in real example

Realm_RxSwift This simple app was written to introduce basic operations of some

An example app showing how to use AVCaptureSession with Metal in Swift.
An example app showing how to use AVCaptureSession with Metal in Swift.

#iOSSwiftMetalCamera Click here to see video demo. This app is a basic example showing how to use Swift to setup an AVCaptureSession session to access

Just simple template - example how to use haptics in iOS Development

Haptics Just simple template - example how to use haptics in iOS Development imp

Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

The easiest way to use Bluetooth (BLE )in ios,even bady can use.
The easiest way to use Bluetooth (BLE )in ios,even bady can use.

The easiest way to use Bluetooth (BLE )in ios,even bady can use.

Are you sure the chemical compounds of your daily use are 100% safe? Use Chem-Aware, identify them right now!
Are you sure the chemical compounds of your daily use are 100% safe? Use Chem-Aware, identify them right now!

View Project On Devpost: Built With: PubChem's REST API How To Install Chem Aware: Prerequiste: Latest Version of Xcode and Simulators installed The a

A keychain wrapper that is so easy to use that your cat could use it.

A keychain wrapper that is so easy to use that your cat could use it.

iOS app for Technex, IIT(BHU) Varanasi. This project is closed before completion. You can use this app for learning purpose. You can use this app as a templet of any event related app.
iOS app for Technex, IIT(BHU) Varanasi. This project is closed before completion. You can use this app for learning purpose. You can use this app as a templet of any event related app.

technex-ios iOS app for Technex, IIT(BHU) Varanasi. This project is closed before completion for some reasons. You can use this app for learning purpo

(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ๐Ÿฏ to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Kraken - Simple Dependency Injection container for Swift. Use protocols to resolve dependencies with easy-to-use syntax!
Kraken - Simple Dependency Injection container for Swift. Use protocols to resolve dependencies with easy-to-use syntax!

Kraken Photo courtesy of www.krakenstudios.blogspot.com Introduction Kraken is a simple Dependency Injection Container. It's aimed to be as simple as

Keep track of accessibility settings, leverage high contrast colors, and use scalable fonts to enable users with disabilities to use your app.
Keep track of accessibility settings, leverage high contrast colors, and use scalable fonts to enable users with disabilities to use your app.

Accessibility for iOS, macOS, tvOS, and watchOS ๐ŸŽ‰ What's new in Capable 2.0 ๐ŸŽ‰ Here are the most important changes: ๐Ÿ› New framework architecture and

(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey ๐Ÿฏ to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Example of Clean Architecture of iOS app using RxSwift
Example of Clean Architecture of iOS app using RxSwift

Clean architecture with RxSwift Contributions are welcome and highly appreciated!! You can do this by: opening an issue to discuss the current solutio

Owner
Gagan Vishal Mishra
Mobile app developer. Swift, Objective-C, AnjgularJS, HTML, Xamarin, Backbase, Flutter & React-Native. Specialization in Banking & Insurance domain.
Gagan Vishal Mishra
This repository contains ๐ŸŽจ My Xcode theme that I use. It is compatible with all versions of Xcode.

DRL Xcodetheme Installation Automatic (via script) ./install.sh which will install the file in Xcode FontAndColorThemes directory. Restart Xcode Go t

durul dalkanat 19 Oct 21, 2022
Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController.

Todo Todo is an iOS App written in Swift. This app is used for an online video training course. This app demonstrates how to use UITableViewController

Jake Lin 273 Dec 29, 2022
Dynamically hide / show cells of static UITableViewController

Dynamically hide / show cells of static UITableViewController, Swift Port of StaticDataTableViewController. Installation CocoaPods pod 'StaticTableVie

muyexi 26 Sep 16, 2022
Simple and lightweight UITableViewController with accordion effect (expand / collapse cells)

AEAccordion UITableViewController with accordion effect (expand / collapse cells) Simple and lightweight solution for making accordion effect in table

Marko Tadiฤ‡ 211 Apr 18, 2022
Protocol-oriented UITableView management, powered by generics and associated types.

DTTableViewManager Features Powerful mapping system between data models and cells, headers and footers Automatic datasource and interface synchronizat

Denys Telezhkin 454 Nov 9, 2022
Protocol-oriented UICollectionView management, powered by generics and associated types.

DTCollectionViewManager Features Powerful mapping system between data models and cells, headers and footers Automatic datasource and interface synchro

Denys Telezhkin 308 Jan 6, 2023
Unidirectional flow implemented using the latest Swift Generics and Swift Concurrency features.

swift-unidirectional-flow Unidirectional flow implemented using the latest Swift Generics and Swift Concurrency features. struct SearchState: Equatabl

Majid Jabrayilov 104 Dec 26, 2022
A hobby project using Swift protocol and Swift 5.7's new generics to build an iOS Calculator-like calculator.

Calculator A hobby project using Swift protocol and Swift 5.7's new generics to build an iOS Calculator-like calculator. Highlights: You can use Calcu

Kyle 4 Oct 24, 2022
Implementation of the repository pattern in Swift, using generics.

Store Simple, powerful and elegant implementation of the repository pattern, using generics. Why? ?? There are a couple of ways to implement the Repos

Narek Mailian 2 Aug 31, 2022
NintendoSwitch-BezierPath-Example - Nintendo Switch Bezier Path Example

NintendoSwitch-BezierPath-Example An example app that demonstrates the use of Be

Juan Vasquez 0 Jan 12, 2022