Created
August 29, 2016 11:09
-
-
Save fromkk/4a0cf13860cc7ad4d4691af32ce48578 to your computer and use it in GitHub Desktop.
最近はこうする事が多いかな #love_swift #CodePiece #akiba_swift
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
import UIKit | |
public protocol ReusableTableViewCell: class { | |
static var cellIdentifier: String { get } | |
static func reusableTableView<T>(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> T | |
} | |
extension ReusableTableViewCell { | |
public static func reusableTableView<T>(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> T { | |
guard let cell: T = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier, forIndexPath: indexPath) as? T else { | |
fatalError("cell reuse failed") | |
} | |
return cell | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment