Skip to content

Commit

Permalink
Merge pull request #13 from narirou/master
Browse files Browse the repository at this point in the history
Replace T with argument of Type
  • Loading branch information
AliSoftware committed Mar 1, 2016
2 parents ec6f8ec + 0ab0931 commit fe41c44
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Sources/Reusable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public extension UITableView {
- seealso: `registerNib(_:,forCellReuseIdentifier:)`
*/
final func registerReusableCell<T: UITableViewCell where T: NibReusable>(cellType: T.Type) {
self.registerNib(T.nib, forCellReuseIdentifier: T.reuseIdentifier)
self.registerNib(cellType.nib, forCellReuseIdentifier: cellType.reuseIdentifier)
}

/**
Expand All @@ -44,7 +44,7 @@ public extension UITableView {
- seealso: `registerClass(_:,forCellReuseIdentifier:)`
*/
final func registerReusableCell<T: UITableViewCell where T: Reusable>(cellType: T.Type) {
self.registerClass(T.self, forCellReuseIdentifier: T.reuseIdentifier)
self.registerClass(cellType.self, forCellReuseIdentifier: cellType.reuseIdentifier)
}

/**
Expand Down Expand Up @@ -78,7 +78,7 @@ public extension UITableView {
- seealso: `registerNib(_:,forHeaderFooterViewReuseIdentifier:)`
*/
final func registerReusableHeaderFooterView<T: UITableViewHeaderFooterView where T: NibReusable>(viewType: T.Type) {
self.registerNib(T.nib, forHeaderFooterViewReuseIdentifier: T.reuseIdentifier)
self.registerNib(viewType.nib, forHeaderFooterViewReuseIdentifier: viewType.reuseIdentifier)
}

/**
Expand All @@ -89,7 +89,7 @@ public extension UITableView {
- seealso: `registerClass(_:,forHeaderFooterViewReuseIdentifier:)`
*/
final func registerReusableHeaderFooterView<T: UITableViewHeaderFooterView where T: Reusable>(viewType: T.Type) {
self.registerClass(T.self, forHeaderFooterViewReuseIdentifier: T.reuseIdentifier)
self.registerClass(viewType.self, forHeaderFooterViewReuseIdentifier: viewType.reuseIdentifier)
}

/**
Expand Down Expand Up @@ -126,7 +126,7 @@ public extension UICollectionView {
- seealso: `registerNib(_:,forCellWithReuseIdentifier:)`
*/
final func registerReusableCell<T: UICollectionViewCell where T: NibReusable>(cellType: T.Type) {
self.registerNib(T.nib, forCellWithReuseIdentifier: T.reuseIdentifier)
self.registerNib(cellType.nib, forCellWithReuseIdentifier: cellType.reuseIdentifier)
}

/**
Expand All @@ -137,7 +137,7 @@ public extension UICollectionView {
- seealso: `registerClass(_:,forCellWithReuseIdentifier:)`
*/
final func registerReusableCell<T: UICollectionViewCell where T: Reusable>(cellType: T.Type) {
self.registerClass(T.self, forCellWithReuseIdentifier: T.reuseIdentifier)
self.registerClass(cellType.self, forCellWithReuseIdentifier: cellType.reuseIdentifier)
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ public extension UICollectionView {
- seealso: `registerNib(_:,forSupplementaryViewOfKind:,withReuseIdentifier:)`
*/
final func registerReusableSupplementaryView<T: UICollectionReusableView where T: NibReusable>(elementKind: String, viewType: T.Type) {
self.registerNib(T.nib, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: T.reuseIdentifier)
self.registerNib(viewType.nib, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: viewType.reuseIdentifier)
}

/**
Expand All @@ -184,7 +184,7 @@ public extension UICollectionView {
- seealso: `registerClass(_:,forSupplementaryViewOfKind:,withReuseIdentifier:)`
*/
final func registerReusableSupplementaryView<T: UICollectionReusableView where T: Reusable>(elementKind: String, viewType: T.Type) {
self.registerClass(T.self, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: T.reuseIdentifier)
self.registerClass(viewType.self, forSupplementaryViewOfKind: elementKind, withReuseIdentifier: viewType.reuseIdentifier)
}

/**
Expand All @@ -202,7 +202,7 @@ public extension UICollectionView {
*/
final func dequeueReusableSupplementaryView<T: UICollectionReusableView where T: Reusable>
(elementKind: String, indexPath: NSIndexPath, viewType: T.Type = T.self) -> T {
let view = self.dequeueReusableSupplementaryViewOfKind(elementKind, withReuseIdentifier: viewType.reuseIdentifier, forIndexPath: indexPath)
let view = self.dequeueReusableSupplementaryViewOfKind(elementKind, withReuseIdentifier: viewType.reuseIdentifier, forIndexPath: indexPath)
guard let typedView = view as? T else {
fatalError(
"Failed to dequeue a supplementary view with identifier \(viewType.reuseIdentifier) matching type \(viewType.self). "
Expand Down

0 comments on commit fe41c44

Please sign in to comment.