-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllGroupsVC.swift
73 lines (51 loc) · 2.29 KB
/
AllGroupsVC.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
//
// AllGroupsVC.swift
// subline
//
// Created by Nate Lohn on 5/5/16.
// Copyright © 2016 Nate Lohn. All rights reserved.
//
import UIKit
import Parse
class AllGroupsVC: UIViewController {
@IBOutlet weak var groupTableView: UITableView!
var db = DataBase()
var username = ""
var selectedGroupName = ""
var groupnames = [String]()
override func viewDidLoad() {
super.viewDidLoad()
print("All Groups VC's user = \(username)")
groupnames = db.getAllUsersGroupNames(username)
print("All groups VC groupnames = \(groupnames)")
groupTableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
//table view logic
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return groupnames.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = groupTableView.dequeueReusableCellWithIdentifier("cell")! as UITableViewCell
cell.textLabel!.text = groupnames[indexPath.row]
return cell
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
selectedGroupName = groupnames[indexPath.row]
print("selected = \(selectedGroupName)")
self.performSegueWithIdentifier("toAllSubgroupsVC", sender: self) //not sure if self should be something else
}
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 50 //height of the post table cell in the xib file
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "toCreateGroupVC"{
let DestinationViewController : CreateGroupVC = segue.destinationViewController as! CreateGroupVC
DestinationViewController.username = username
}
if segue.identifier == "toAllSubgroupsVC"{
let DestinationViewController : AllSubgroupsVC = segue.destinationViewController as! AllSubgroupsVC
DestinationViewController.username = username
DestinationViewController.groupName = selectedGroupName
}
}
}