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

Extract reward cell to its own nib #88

Merged
merged 2 commits into from
Feb 10, 2017
Merged

Extract reward cell to its own nib #88

merged 2 commits into from
Feb 10, 2017

Conversation

mbrandonw
Copy link
Contributor

Been tinkering with how we can reuse table view cells across multiple controllers/storyboards, and turns out it's very easy. So, I took a shot at doing this for our RewardCell, which is definitely our most complicated cell. I did this one cause some future work is gonna bring rewards into some new views.

To do this I literally just cut+pasted the cell from the storyboard to a brand new *.xib file. Then I have to do an explicit self.tableView.register(nib) step in the controller because that's what the storyboard + prototype cell does for you. But after that it just worked!

Copy link
Contributor

@theginbin theginbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, nice and clean

@@ -28,6 +28,9 @@ public final class ProjectPamphletContentViewController: UITableViewController {
self, action: #selector(scrollViewPanGestureRecognizerDidChange(_:))
)

self.tableView.register(UINib(nibName: "RewardCell", bundle: Bundle.framework),
forCellReuseIdentifier: "RewardCell")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be nice to put this in a new enum in Storyboard.swift?

extension UITableView {
public func register(nib: Nib, inBundle bundle: Bundle = .framework) {
self.register(UINib(nibName: nib.rawValue, bundle: bundle), forCellReuseIdentifier: nib.rawValue)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great suggestion!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know how much i love enums

Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking at this going cool but where are the rest of the changes??

Nice! Glad it's so simple. Cell's having their own view models certainly makes this easier too.

@mbrandonw mbrandonw merged commit b977585 into master Feb 10, 2017
@mbrandonw mbrandonw deleted the reuse-reward-cell branch March 29, 2017 13:40
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 this pull request may close these issues.

None yet

3 participants