-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeftViewController.m
More file actions
105 lines (81 loc) · 3.53 KB
/
LeftViewController.m
File metadata and controls
105 lines (81 loc) · 3.53 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
104
105
//
// LeftViewController.m
// SplitView
//
// Created by Matheus Pacheco Fusco on 30/08/16.
// Copyright © 2016 MatheusFusco. All rights reserved.
//
#import "LeftViewController.h"
#import "Monster.h"
@interface LeftViewController ()
@end
@implementation LeftViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Monsters";
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
_monsters = [NSMutableArray array];
//Create monster objects then add them to the array.
[_monsters addObject:[Monster newMonsterWithName:@"Cat-Bot"
description:@"MEE-OW"
iconName:@"meetcatbot.png"
weapon:[Weapon newWeaponOfType:Sword]]];
[_monsters addObject:[Monster newMonsterWithName:@"Dog-Bot"
description:@"BOW-WOW"
iconName:@"meetdogbot.png"
weapon:[Weapon newWeaponOfType:Blowgun]]];
[_monsters addObject:[Monster newMonsterWithName:@"Explode-Bot"
description:@"Tick, tick, BOOM!"
iconName:@"meetexplodebot.png"
weapon:[Weapon newWeaponOfType:Smoke]]];
[_monsters addObject:[Monster newMonsterWithName:@"Fire-Bot"
description:@"Will Make You Steamed"
iconName:@"meetfirebot.png"
weapon:[Weapon newWeaponOfType:NinjaStar]]];
[_monsters addObject:[Monster newMonsterWithName:@"Ice-Bot"
description:@"Has A Chilling Effect"
iconName:@"meeticebot.png"
weapon:[Weapon newWeaponOfType:Fire]]];
[_monsters addObject:[Monster newMonsterWithName:@"Mini-Tomato-Bot"
description:@"Extremely Handsome"
iconName:@"meetminitomatobot.png"
weapon:[Weapon newWeaponOfType:NinjaStar]]];
}
return self;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_monsters count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
Monster *monster = _monsters[indexPath.row];
cell.textLabel.text = monster.name;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
Monster *selectedMonster = [_monsters objectAtIndex:indexPath.row];
if (_delegate) {
[_delegate selectedMonster:selectedMonster];
}
}
#pragma mark - Memory Management
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end