Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import Foundation
- class TodoTableViewController: UITableViewController {
- struct Todo {
- let description : String
- var isDone : Bool = false
- init(description:String) {
- self.description = description
- }
- }
- var todoList = [Todo]()
- var doneList = [Todo]()
- // 중략
- override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- if( isHeaderSection(section)) {
- return 1
- }
- else if( section==1 ) {
- return todoList.count
- }
- return doneList.count
- }
- // 중략
- private func getTodo(rowAtIndexPath indexPath:NSIndexPath)->Todo {
- if( indexPath.section==1 ) {
- return todoList[indexPath.row]
- }
- return doneList[indexPath.row]
- }
- override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
- let cell = getCell(tableView, rowAtIndexPath: indexPath)
- if let todoOrDonCell = cell as? TodoOrDoneTableViewCell {
- if( indexPath.section==0 ) {
- todoOrDonCell.todoOrDoneLabel.text = "ToDo"
- }
- else if( indexPath.section==2 ) {
- todoOrDonCell.todoOrDoneLabel.text = "Done"
- }
- }
- else if let todoCell = cell as? TodoTableViewCell {
- let todo = getTodo(rowAtIndexPath: indexPath)
- todoCell.todoLabel.text = todo.description
- }
- return cell
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement