Skip to content

Instantly share code, notes, and snippets.

View Saraavana's full-sized avatar

Saravanakumar Gopalakrishnan Saraavana

View GitHub Profile
@Saraavana
Saraavana / RegisterGenericCell.swift
Last active May 15, 2017 07:05
It is an extension that registers and returns the UITableViewCell and UICollectionViewCell
//Note: The Nib Name and the identifier should be the same.
extension UITableView
{
func dequeue<T>(_ identifier :String, _ OfClass :T.Type) -> T
{
var cell = self.dequeueReusableCell(withIdentifier: identifier) as? T
if cell == nil
{
self.register(UINib(nibName: identifier, bundle: nil), forCellReuseIdentifier: identifier)