Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace T with argument of Type #13

Merged
merged 2 commits into from
Mar 1, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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