Skip to content

Commit c2851b7

Browse files
committed
SwiftDoc for CollectionVIew
1 parent 5e49ae0 commit c2851b7

File tree

1 file changed

+44
-7
lines changed

1 file changed

+44
-7
lines changed

Library/UIKit/UICollectionView+ReuseIdentifierProtocol.swift

+44-7
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,64 @@ import Foundation
1010
import UIKit
1111

1212
public extension UICollectionView {
13+
/**
14+
Returns a typed reusable cell object located by its identifier
15+
16+
- parameter identifier: The R.reuseIdentifier.* value for the specified cell.
17+
- parameter indexPath: The index path specifying the location of the cell. The data source receives this information when it is asked for the cell and should just pass it along. This method uses the index path to perform additional configuration based on the cell’s position in the collection view.
18+
19+
- returns: A subclass of UICollectionReusableView or nil if the cast fails.
20+
*/
1321
public func dequeueReusableCellWithReuseIdentifier<Identifier: ReuseIdentifierProtocol where Identifier.ReusableType: UICollectionReusableView>(identifier: Identifier, forIndexPath indexPath: NSIndexPath) -> Identifier.ReusableType? {
1422
return dequeueReusableCellWithReuseIdentifier(identifier.identifier, forIndexPath: indexPath) as? Identifier.ReusableType
1523
}
1624

25+
/**
26+
Returns a typed reusable supplementary view located by its identifier and kind.
27+
28+
- parameter elementKind: The kind of supplementary view to retrieve. This value is defined by the layout object.
29+
- parameter identifier: The R.reuseIdentifier.* value for the specified view.
30+
- parameter indexPath: The index path specifying the location of the cell. The data source receives this information when it is asked for the cell and should just pass it along. This method uses the index path to perform additional configuration based on the cell’s position in the collection view.
31+
32+
- returns: A subclass of UICollectionReusableView or nil if the cast fails.
33+
*/
1734
public func dequeueReusableSupplementaryViewOfKind<Identifier: ReuseIdentifierProtocol where Identifier.ReusableType: UICollectionReusableView>(elementKind: String, withReuseIdentifier identifier: Identifier, forIndexPath indexPath: NSIndexPath) -> Identifier.ReusableType? {
1835
return dequeueReusableSupplementaryViewOfKind(elementKind, withReuseIdentifier: identifier.identifier, forIndexPath: indexPath) as? Identifier.ReusableType
1936
}
2037

21-
public func registerNib<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionViewCell>(nibResource: Resource) {
22-
registerNib(nibResource.instance, forCellWithReuseIdentifier: nibResource.identifier)
23-
}
24-
25-
public func registerNib<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionReusableView>(nibResource: Resource, forSupplementaryViewOfKind kind: String) {
26-
registerNib(nibResource.instance, forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource.identifier)
27-
}
38+
/**
39+
Register a serie of R.nib.* for use in creating new collection view cells.
2840

41+
- parameter nibResources: An array of nib resources (R.nib.*) each containing a object of type UICollectionViewCell that has a reuse identifier
42+
*/
2943
public func registerNibs<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionViewCell>(nibResources: [Resource]) {
3044
nibResources.forEach(registerNib)
3145
}
3246

47+
/**
48+
Register a R.nib.* for use in creating new collection view cells.
49+
50+
- parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionViewCell that has a reuse identifier
51+
*/
52+
public func registerNib<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionViewCell>(nibResource: Resource) {
53+
registerNib(nibResource.instance, forCellWithReuseIdentifier: nibResource.identifier)
54+
}
55+
56+
/**
57+
Register a serie of R.nib.* for use in creating supplementary views for the collection view.
58+
59+
- parameter nibResources: An array of nib resources (R.nib.*) each containing a object of type UICollectionReusableView. that has a reuse identifier
60+
*/
3361
public func registerNibs<Resource: NibResource where Resource: ReuseIdentifierProtocol, Resource.ReusableType: UICollectionReusableView>(nibResources: [Resource], forSupplementaryViewOfKind kind: String) {
3462
nibResources.forEach { self.registerNib($0, forSupplementaryViewOfKind: kind) }
3563
}
64+
65+
/**
66+
Register a R.nib.* for use in creating supplementary views for the collection view.
67+
68+
- parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionReusableView. that has a reuse identifier
69+
*/
70+
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)
72+
}
3673
}

0 commit comments

Comments
 (0)