-
Notifications
You must be signed in to change notification settings - Fork 0
/
PushedViewController.m
executable file
·112 lines (82 loc) · 3.52 KB
/
PushedViewController.m
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
//
// PushedViewController.m
// Login
//
// Created by Dev on 10/23/14.
// Copyright (c) 2014 Dev. All rights reserved.
//
#import "PushedViewController.h"
#import <Parse/Parse.h>
@interface PushedViewController (){
NSArray *links;
NSArray *sports;
NSMutableDictionary *existingSports;
PFObject *school;
NSMutableArray *sportsFound;
}
@end
@implementation PushedViewController
-(void)viewWillAppear:(BOOL)animated{
self.hidesBottomBarWhenPushed = YES;
self.title = [_container objectAtIndex:0];
school = [_container objectAtIndex:1];
// NSLog(@"%s",[[[_container objectAtIndex:1] description]UTF8String]);
PFQuery *query = [PFQuery queryWithClassName:@"Sports"];
sports = [query findObjects];
// NSLog(@"%s",[[sports description]UTF8String]);
existingSports = [[NSMutableDictionary alloc]init];
sportsFound = [[NSMutableArray alloc]init];
// NSLog(@"%s",[[[school objectForKey:[sports objectAtIndex:0][@"Name"]] description]UTF8String]);
for(int i = 0; i < sports.count; i++){
// NSString *link = [school objectForKey:[sports objectAtIndex:i][@"Name"]];
// if(![link isEqual: nil]){
// [existingSports addEntriesFromDictionary:[NSDictionary dictionaryWithObject:link forKey:sports[i]]];
// }
NSString *currentSport =[sports objectAtIndex:i ] [@"Name"];
if([school objectForKey:currentSport]){
[sportsFound addObject:currentSport];
// NSLog(@"%s and %s",[currentSport UTF8String], [[school objectForKey:currentSport] UTF8String]);
[existingSports addEntriesFromDictionary:[NSDictionary dictionaryWithObject:[school objectForKey:currentSport] forKey:currentSport]];
}
}
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//self.title = [_container objectAtIndex:0];
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
[self.navigationItem setHidesBackButton:YES animated:NO];// = nil;
[self.tableView setDataSource:self];
[self.tableView setDelegate:self];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
// NSLog(@"%s",[[existingSports description]UTF8String]);
// NSLog(@"%s",[[sportsFound description]UTF8String]);
return existingSports.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
//cell.textLabel.text = [NSString stringWithFormat:@"%d",indexPath.row+1];
cell.textLabel.text = [existingSports objectForKey:[sportsFound objectAtIndex:indexPath.row]];
//NSLog(@"%s",[[existingSports objectForKey:[sportsFound objectAtIndex:indexPath.row]] UTF8String]);
return cell;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (IBAction)manualBack:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
@end