forked from jsonmodel/jsonmodel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMasterViewController.m
More file actions
103 lines (83 loc) · 3.28 KB
/
MasterViewController.m
File metadata and controls
103 lines (83 loc) · 3.28 KB
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
//
// MasterViewController.m
// JSONModelDemo
//
// Created by Marin Todorov on 02/12/2012.
// Copyright (c) 2012 Underplot ltd. All rights reserved.
//
#import "MasterViewController.h"
#import "KivaViewController.h"
#import "GitHubViewController.h"
#import "YouTubeViewController.h"
#import "StorageViewController.h"
#import "KivaViewControllerNetworking.h"
#import "JSONModel+networking.h"
#import "VideoModel.h"
@interface MasterViewController () {
NSMutableArray *_objects;
}
@end
@implementation MasterViewController
-(void)viewDidAppear:(BOOL)animated
{
//[self tableView: self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = @"Demos";
_objects = [NSMutableArray arrayWithArray:@[@"Kiva.org demo", @"GitHub demo", @"Youtube demo", @"Used for storage", @"Kiva.org + own networking"]];
}
return self;
}
#pragma mark - Table View
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _objects.count;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
NSDate *object = _objects[indexPath.row];
cell.textLabel.text = [object description];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:{
KivaViewController* kiva = [[KivaViewController alloc] initWithNibName:@"KivaViewController" bundle:nil];
[self.navigationController pushViewController:kiva animated:YES];
}break;
case 1:{
GitHubViewController* gh = [[GitHubViewController alloc] initWithNibName:@"GitHubViewController" bundle:nil];
[self.navigationController pushViewController:gh animated:YES];
}break;
case 2:{
YouTubeViewController* yt = [[YouTubeViewController alloc] initWithNibName:@"YouTubeViewController" bundle:nil];
[self.navigationController pushViewController:yt animated:YES];
}break;
case 3:{
StorageViewController* sc = [[StorageViewController alloc] initWithNibName:@"StorageViewController" bundle:nil];
[self.navigationController pushViewController:sc animated:YES];
}break;
case 4:{
KivaViewControllerNetworking* sc = [[KivaViewControllerNetworking alloc] initWithNibName:@"KivaViewControllerNetworking" bundle:nil];
[self.navigationController pushViewController:sc animated:YES];
}break;
default:
break;
}
}
@end