<commit_before>//
//  TableViewHelpers.swift
//  Pods
//
//  Created by <NAME> on 5/20/16.
//
//

import Foundation

//based on https://medium.com/@calebd/swift-reusable-cells-31391d2f2906#.owjb1kpk2
extension UITableView {
    public final func registerReusableCell<T>(_ cell: ReusableCell<T>) where T: UITableViewCell {
        switch cell {
        case .class(let identifier):
            register(T.self, forCellReuseIdentifier: identifier)
        case .nib(let identifier, let nibName, let bundle):
            let nib = UINib(nibName: nibName, bundle: bundle)
            register(nib, forCellReuseIdentifier: identifier)
        }
    }
    
    public final func dequeueReusableCell<T>(_ cell: ReusableCell<T>, indexPath: NSIndexPath) -> T where T: UITableViewCell {
        guard let cell = dequeueReusableCell(withIdentifier: cell.identifier, for: indexPath as IndexPath) as? T else {
            assertionFailure("type error how is this possible?")
            return T()
        }
        return cell
    }
}

public enum ReusableCell<Cell> {
    case `class`(identifier: String)<commit_msg>Fixed casting issue that was making indexPath as NSIndexPath<commit_after>//
//  TableViewHelpers.swift
//  Pods
//
//  Created by <NAME> on 5/20/16.
//
//

import Foundation

//based on https://medium.com/@calebd/swift-reusable-cells-31391d2f2906#.owjb1kpk2
extension UITableView {
    public final func registerReusableCell<T>(_ cell: ReusableCell<T>) where T: UITableViewCell {
        switch cell {
        case .class(let identifier):
            register(T.self, forCellReuseIdentifier: identifier)
        case .nib(let identifier, let nibName, let bundle):
            let nib = UINib(nibName: nibName, bundle: bundle)
            register(nib, forCellReuseIdentifier: identifier)
        }
    }
    
    public final func dequeueReusableCell<T>(_ cell: ReusableCell<T>, indexPath: IndexPath) -> T where T: UITableViewCell {
        guard let cell = dequeueReusableCell(withIdentifier: cell.identifier, for: indexPath) as? T else {
            assertionFailure("type error how is this possible?")
            return T()
        }
        return cell
    }
}

public enum ReusableCell<Cell> {
    case `class`(identifier: String)
{'fraction_non_alphanumeric': 0.10258697591436218, 'fraction_numerical': 0.015165031222123104, 'mean_word_length': 2.8473413379073755, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3498403', 'n_tokens_mistral': 726, 'n_tokens_neox': 664, 'n_words': 181}