Created
October 29, 2018 06:00
-
-
Save amannayak0007/d00bf801c51bd020587d30ac90eea074 to your computer and use it in GitHub Desktop.
Method for dequeueReusableCell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UITableView.swift | |
import UIKit | |
/** | |
* Extension to provide extra capabilities to existing UITableView. | |
*/ | |
extension UITableView{ | |
/** | |
* Method for dequeueReusableCell. | |
* | |
* @param T UITableViewCell | |
* @return T UITableViewCell | |
*/ | |
func dequeueReusableCell<T:UITableViewCell>(type: T.Type) -> T? { | |
var fullName: String = NSStringFromClass(T.self) | |
if let range = fullName.range(of:".", options:.backwards, range:nil, locale: nil){ | |
fullName = fullName.substring(from: range.upperBound) | |
} | |
return self.dequeueReusableCell(withIdentifier: fullName) as? T | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment