-
Notifications
You must be signed in to change notification settings - Fork 1
/
CoursesListViewController.swift
162 lines (104 loc) · 4.7 KB
/
CoursesListViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
//
// CoursesListViewController.swift
// above-average
//
// Created by Kyra Drake on 1/15/16.
// Copyright © 2016 Kyra Drake. All rights reserved.
//
import UIKit
//semesterArrayIndex
class CoursesListViewController: UIViewController, UITableViewDelegate {
@IBOutlet weak var menuButton: UIBarButtonItem!
@IBOutlet weak var semesterCoursesTable: UITableView!
@IBOutlet weak var semesterNameLabel: UILabel!
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if semesterArray.count == 0 {
return 0
}
else {
return semesterArray[semesterArrayIndex].courses.count
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
cell.accessoryType = .DetailDisclosureButton
cell.textLabel?.text = semesterArray[semesterArrayIndex].courses[indexPath.row].name + " " + String(semesterArray[semesterArrayIndex].courses[indexPath.row].overallPercent)
return cell
}
func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
let index = indexPath.row
print(index)
print("jkalsnvkdlsankldvkmsaksdnvdlsaksnvkldsnaklsnkglnasklcmlajewkn")
courseIndex = index
performSegueWithIdentifier("goToCourse", sender: self)
}
/*
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete { //swipee to the left (delete)
toDoList.removeAtIndex(indexPath.row)
NSUserDefaults.standardUserDefaults().setObject(toDoList, forKey: "toDoList")
toDoListTable.reloadData()
}
}
*/
override func viewDidAppear(animated: Bool) {
semesterCoursesTable.reloadData()
//semesterNameLabel.text = semesterArray[semesterArrayIndex].term
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if self.revealViewController() != nil {
menuButton.target = self.revealViewController()
menuButton.action = "revealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
/*
import UIKit
//var courseArray = [Course]()
class CoursesListViewController: UIViewController {
//@IBOutlet weak var semesterMenuButton: UIBarButtonItem!
@IBOutlet weak var semesterCoursesTable: UITableView!
//SEMESTER COURSES TABLE STUFF
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
// return courseArray.count //return number of courses in the semester
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
cell.textLabel?.text = "cell"
//cell.textLabel?.text = courseArray[indexPath.row].name + " " + String(courseArray[indexPath.row].overallPercent)
return cell
}
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == UITableViewCellEditingStyle.Delete { //swipee to the left (delete)
//toDoList.removeAtIndex(indexPath.row)
//semesterCoursesTable.reloadData()
}
}
override func viewDidAppear(animated: Bool) {
semesterCoursesTable.reloadData()
}
//OTHER STUFF
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
/*
if self.revealViewController() != nil {
semesterMenuButton.target = self.revealViewController()
semesterMenuButton.action = "revealToggle:"
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}*/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
*/