-
Notifications
You must be signed in to change notification settings - Fork 9
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
Create Basic App #1
base: jack_review
Are you sure you want to change the base?
Conversation
// DRY this up -> The topButton and bottomButton should listen for state changes on the player | ||
// @Jack: What is the cleanest way to do this? | ||
// Make another controller for each half? | ||
// Maybe also make the Player model observable with: https://github.com/slazyk/Observable-Swift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like Key-Value Observing doesn't work quite the same way in swift as Obj-C. It might be good to use swift's built in Property Observers or the the Observable Swift Library built on top of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. Haven't looked at any of that yet.
I actually think this logic should probably also live in a custom view. You could define a method on it (called, say, updateWithViewModel) that would take in a bunch of state and then update all the relevant UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, and then I would have two instances of the custom view. One for the top and one for the bottom. I'll look up examples of people using custom views in swift. Thanks!
So yeah, broadly speaking I think you should have a TimeView class of some sort that knows how to display the remaining time and can report button presses to your view controller via a delegate pattern or something. There is prooobably too much logic in your ViewController right now (an extremely common antipattern of which i am often guilty). There is a good blog post on how you can mitigate this here: http://khanlou.com/2014/09/8-patterns-to-help-you-destroy-massive-view-controller/ |
All business logic is in ViewController.swift