Skip to content

Instantly share code, notes, and snippets.

@fromkk
Created August 29, 2016 11:09
Show Gist options
  • Save fromkk/4a0cf13860cc7ad4d4691af32ce48578 to your computer and use it in GitHub Desktop.
Save fromkk/4a0cf13860cc7ad4d4691af32ce48578 to your computer and use it in GitHub Desktop.
最近はこうする事が多いかな #love_swift #CodePiece #akiba_swift
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