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

inherited class behavior #12

Closed
narirou opened this issue Feb 29, 2016 · 0 comments · Fixed by #13
Closed

inherited class behavior #12

narirou opened this issue Feb 29, 2016 · 0 comments · Fixed by #13

Comments

@narirou
Copy link
Contributor

narirou commented Feb 29, 2016

Hi.

When this plugin registered inherited cell, it does dequeueReusableCell as its supperclass.
In this case, it will occur crash because registered class and dequeued class is different.

class BaseCell: UICollectionViewCell, Reusable {}
class MyCell: BaseCell {}

let cellType: BaseCell.Type = MyCell.self

class CollectionViewController: UICollectionViewController {
  override func viewDidLoad() {

    // it is registered as "BaseCell". But I think this cell should be registered as "MyCell".
    collectionView.registerReusableCell(cellType)
  }

  override func collectionView(collectionView: UICollectionView,
    cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    // in this statement, the cell is "MyCell". (will be crashed)
    let cell = collectionView.dequeueReusableCell(indexPath: indexPath, cellType: cellType)

    return cell
  }

  // ...
}

If possible, I will send a pull-request. :)
Thanks.

@narirou narirou changed the title behavior when inherited class inherited class behavior Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant