Skip to content

Commit 7eaca03

Browse files
committed
Merge pull request #5 from hyperoslo/fix/reuse-identifier
Move reuseIdentifier into static string
2 parents 2a79598 + 6dd8124 commit 7eaca03

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Source/ComponentController.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import UIKit
33
class ComponentsController: UIViewController {
44

55
private let componentViews: [ComponentView]
6+
static let reuseIdentifier = "ComponentCell"
67

78
lazy var collectionView: UICollectionView = { [unowned self] in
89
let layout = UICollectionViewFlowLayout()
910
layout.itemSize = self.view.bounds.size
1011

1112
let collectionView = UICollectionView(frame: UIScreen.mainScreen().bounds, collectionViewLayout: layout)
1213
collectionView.dataSource = self
13-
collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "ComponentCell")
14+
collectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
1415

1516
return collectionView
1617
}()
@@ -34,7 +35,7 @@ extension ComponentsController: UICollectionViewDataSource {
3435

3536
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
3637
let view = componentViews[indexPath.item]
37-
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("ComponentCell", forIndexPath: indexPath)
38+
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(ComponentsController.reuseIdentifier, forIndexPath: indexPath)
3839
cell.contentView.addSubview(view.render())
3940
return cell
4041
}

0 commit comments

Comments
 (0)