Skip to content
This repository was archived by the owner on Sep 19, 2024. It is now read-only.

Commit 05b8451

Browse files
committed
SwiftDoc for nib + instance is now a function
1 parent 01394bb commit 05b8451

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

Library/Core/NibResource.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@
88

99
import Foundation
1010

11+
/// Represents a nib file on disk
1112
public protocol NibResource {
13+
14+
/// Bundle this nib is in or nil for main bundle
1215
var bundle: NSBundle? { get }
13-
var instance: UINib { get }
16+
17+
/// Name of the nib file on disk
1418
var name: String { get }
19+
20+
/**
21+
Create a new instance of this nib file
22+
23+
- returns: A new instance of this nib
24+
*/
25+
func instantiate() -> UINib
1526
}

Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public extension UICollectionView {
5050
- parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionViewCell that has a reuse identifier
5151
*/
5252
public func registerNib<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionViewCell>(nibResource: Resource) {
53-
registerNib(nibResource.instance, forCellWithReuseIdentifier: nibResource.identifier)
53+
registerNib(nibResource.instantiate(), forCellWithReuseIdentifier: nibResource.identifier)
5454
}
5555

5656
/**
@@ -68,6 +68,6 @@ public extension UICollectionView {
6868
- parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionReusableView. that has a reuse identifier
6969
*/
7070
public func registerNib<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionReusableView>(nibResource: Resource, forSupplementaryViewOfKind kind: String) {
71-
registerNib(nibResource.instance, forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource.identifier)
71+
registerNib(nibResource.instantiate(), forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource.identifier)
7272
}
7373
}

Library/UIKit/UITableView+ReuseIdentifierProtocol.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public extension UITableView {
6363
- parameter nibResource: A nib resource (R.nib.*) containing a table view cell that has a reuse identifier
6464
*/
6565
public func registerNib<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UITableViewCell>(nibResource: Resource) {
66-
registerNib(nibResource.instance, forCellReuseIdentifier: nibResource.identifier)
66+
registerNib(nibResource.instantiate(), forCellReuseIdentifier: nibResource.identifier)
6767
}
6868

6969
/**
@@ -72,6 +72,6 @@ public extension UITableView {
7272
- parameter nibResource: A nib resource (R.nib.*) containing a view that has a reuse identifier
7373
*/
7474
public func registerNibForHeaderFooterView<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UIView>(nibResource: Resource) {
75-
registerNib(nibResource.instance, forHeaderFooterViewReuseIdentifier: nibResource.identifier)
75+
registerNib(nibResource.instantiate(), forHeaderFooterViewReuseIdentifier: nibResource.identifier)
7676
}
7777
}

0 commit comments

Comments
 (0)