Created
December 3, 2018 08:58
-
-
Save rockname/7a2945d1f7c0c9079ae5d2f0bea3af9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CommonizedDataSource: NSObject, UITableViewDataSource { | |
| private var values: [(headerTitle: String?, rows: [(value: Any, reusableId: String)])] = [] | |
| func load(_ tasks: [Task]) { | |
| self.values = [ | |
| ( | |
| headerTitle: nil, | |
| rows: [(value: (), reusableId: "ProfileTableViewCell")] | |
| ), | |
| ( | |
| headerTitle: Category.personal.rawValue, | |
| rows: tasks.filter { $0.category == .personal }.map { (value: $0, reusableId: "TaskTableViewCell") } | |
| ), | |
| ( | |
| headerTitle: Category.shopping.rawValue, | |
| rows: tasks.filter { $0.category == .personal }.map { (value: $0, reusableId: "TaskTableViewCell") } | |
| ), | |
| ( | |
| headerTitle: Category.work.rawValue, | |
| rows: tasks.filter { $0.category == .personal }.map { (value: $0, reusableId: "TaskTableViewCell") } | |
| ) | |
| ] as! [(headerTitle: String?, rows: [(value: Any, reusableId: String)])] | |
| } | |
| . | |
| . | |
| . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment