@@ -18,8 +18,10 @@ public extension UICollectionView {
18
18
19
19
- returns: A subclass of UICollectionReusableView or nil if the cast fails.
20
20
*/
21
- public func dequeueReusableCellWithReuseIdentifier< Identifier: ReuseIdentifierType where Identifier. ReusableType: UICollectionReusableView > ( identifier: Identifier , forIndexPath indexPath: NSIndexPath ) -> Identifier . ReusableType ? {
22
- return dequeueReusableCellWithReuseIdentifier ( identifier. identifier, forIndexPath: indexPath) as? Identifier . ReusableType
21
+ public func dequeueReusableCell< Identifier: ReuseIdentifierType > ( withReuseIdentifier identifier: Identifier , for indexPath: IndexPath ) -> Identifier . ReusableType ?
22
+ where Identifier. ReusableType: UICollectionReusableView
23
+ {
24
+ return dequeueReusableCell ( withReuseIdentifier: identifier. identifier, for: indexPath) as? Identifier . ReusableType
23
25
}
24
26
25
27
/**
@@ -31,43 +33,53 @@ public extension UICollectionView {
31
33
32
34
- returns: A subclass of UICollectionReusableView or nil if the cast fails.
33
35
*/
34
- public func dequeueReusableSupplementaryViewOfKind< Identifier: ReuseIdentifierType where Identifier. ReusableType: UICollectionReusableView > ( elementKind: String , withReuseIdentifier identifier: Identifier , forIndexPath indexPath: NSIndexPath ) -> Identifier . ReusableType ? {
35
- return dequeueReusableSupplementaryViewOfKind ( elementKind, withReuseIdentifier: identifier. identifier, forIndexPath: indexPath) as? Identifier . ReusableType
36
+ public func dequeueReusableSupplementaryView< Identifier: ReuseIdentifierType > ( ofKind elementKind: String , withReuseIdentifier identifier: Identifier , for indexPath: IndexPath ) -> Identifier . ReusableType ?
37
+ where Identifier. ReusableType: UICollectionReusableView
38
+ {
39
+ return dequeueReusableSupplementaryView ( ofKind: elementKind, withReuseIdentifier: identifier. identifier, for: indexPath) as? Identifier . ReusableType
36
40
}
37
41
38
42
/**
39
43
Register a serie of R.nib.* for use in creating new collection view cells.
40
44
41
45
- parameter nibResources: An array of nib resources (R.nib.*) each containing a object of type UICollectionViewCell that has a reuse identifier
42
46
*/
43
- public func registerNibs< Resource: NibResourceType where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionViewCell > ( nibResources: [ Resource ] ) {
44
- nibResources. forEach ( registerNib)
47
+ public func register< Resource: NibResourceType > ( _ nibResources: [ Resource ] )
48
+ where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionViewCell
49
+ {
50
+ nibResources. forEach ( register)
45
51
}
46
52
47
53
/**
48
54
Register a R.nib.* for use in creating new collection view cells.
49
55
50
56
- parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionViewCell that has a reuse identifier
51
57
*/
52
- public func registerNib< Resource: NibResourceType where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionViewCell > ( nibResource: Resource ) {
53
- registerNib ( UINib ( resource: nibResource) , forCellWithReuseIdentifier: nibResource. identifier)
58
+ public func register< Resource: NibResourceType > ( _ nibResource: Resource )
59
+ where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionViewCell
60
+ {
61
+ register ( UINib ( resource: nibResource) , forCellWithReuseIdentifier: nibResource. identifier)
54
62
}
55
63
56
64
/**
57
65
Register a serie of R.nib.* for use in creating supplementary views for the collection view.
58
66
59
67
- parameter nibResources: An array of nib resources (R.nib.*) each containing a object of type UICollectionReusableView. that has a reuse identifier
60
68
*/
61
- public func registerNibs< Resource: NibResourceType where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionReusableView > ( nibResources: [ Resource ] , forSupplementaryViewOfKind kind: String ) {
62
- nibResources. forEach { self . registerNib ( $0, forSupplementaryViewOfKind: kind) }
69
+ public func register< Resource: NibResourceType > ( _ nibResources: [ Resource ] , forSupplementaryViewOfKind kind: String )
70
+ where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionReusableView
71
+ {
72
+ nibResources. forEach { self . register ( $0, forSupplementaryViewOfKind: kind) }
63
73
}
64
74
65
75
/**
66
76
Register a R.nib.* for use in creating supplementary views for the collection view.
67
77
68
78
- parameter nibResource: A nib resource (R.nib.*) containing a object of type UICollectionReusableView. that has a reuse identifier
69
79
*/
70
- public func registerNib< Resource: NibResourceType where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionReusableView > ( nibResource: Resource , forSupplementaryViewOfKind kind: String ) {
71
- registerNib ( UINib ( resource: nibResource) , forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource. identifier)
80
+ public func register< Resource: NibResourceType > ( _ nibResource: Resource , forSupplementaryViewOfKind kind: String )
81
+ where Resource: ReuseIdentifierType , Resource. ReusableType: UICollectionReusableView
82
+ {
83
+ register ( UINib ( resource: nibResource) , forSupplementaryViewOfKind: kind, withReuseIdentifier: nibResource. identifier)
72
84
}
73
85
}
0 commit comments