forked from ClassyKit/Classy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCASRootViewController.m
More file actions
64 lines (45 loc) · 1.7 KB
/
Copy pathCASRootViewController.m
File metadata and controls
64 lines (45 loc) · 1.7 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
//
// CASRootViewController.m
// ClassyExample
//
// Created by Jonas Budelmann on 21/10/13.
// Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//
#import "CASRootViewController.h"
#import "CASSimpleFormViewController.h"
#import "CASCatalogViewController.h"
static NSString * const CASRootCellReuseIdentifier = @"CASRootCellReuseIdentifier";
@interface CASRootViewController ()
@property (nonatomic, strong) NSArray *exampleControllers;
@end
@implementation CASRootViewController
- (id)init {
self = [super init];
if (!self) return nil;
self.title = @"Examples";
self.exampleControllers = @[
CASSimpleFormViewController.new,
CASCatalogViewController.new,
];
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView registerClass:UITableViewCell.class forCellReuseIdentifier:CASRootCellReuseIdentifier];
}
#pragma mark - UITableViewDataSource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = self.exampleControllers[indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CASRootCellReuseIdentifier forIndexPath:indexPath];
cell.textLabel.text = viewController.title;
return cell;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.exampleControllers.count;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = self.exampleControllers[indexPath.row];
[self.navigationController pushViewController:viewController animated:YES];
}
@end