-
Notifications
You must be signed in to change notification settings - Fork 0
/
SampleInfoViewController.m
executable file
·99 lines (83 loc) · 2.71 KB
/
SampleInfoViewController.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
//
// SampleInfoViewController.m
// PointInfoViewController
//
// Created by Junfeng Shen on 19/2/12.
// Copyright (c) 2012 SYSU. All rights reserved.
//
#import "SampleInfoViewController.h"
@implementation SampleInfoViewController
@synthesize s;
- (id)initWithSample:(sampleInfo*)samp{
self = [super initWithStyle:UITableViewStyleGrouped];
db = [[DatabaseOperation alloc] init];
self.s = samp;
[db getSignalsForSample:self.s];
self.navigationItem.title = @"SampleInfo";
return self;
}
- (void)dealloc{
[self.s release];
[super dealloc];
}
#pragma mark - View lifecycle
- (void)viewDidLoad{
[super viewDidLoad];
}
- (void)viewDidUnload{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.s.signals.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 5;
}
- (NSString*)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [[self.s.signals objectAtIndex:section] mac];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"] autorelease];
}
switch (indexPath.row) {
case 0:
cell.textLabel.text = @"SSID";
cell.detailTextLabel.text = [[self.s.signals objectAtIndex:indexPath.section] ssid];
break;
case 1:
cell.textLabel.text = @"Mode";
if([[self.s.signals objectAtIndex:indexPath.section] mode] == 2)
cell.detailTextLabel.text = @"Infrastructure";
else
cell.detailTextLabel.text = @"Ad-hoc";
break;
case 2:
cell.textLabel.text = @"RSSI";
cell.detailTextLabel.text = [NSString stringWithFormat:@"%d", [[self.s.signals objectAtIndex:indexPath.section] rssi]];
break;
case 3:
cell.textLabel.text = @"Noise";
cell.detailTextLabel.text = [NSString stringWithFormat:@"%d",[[self.s.signals objectAtIndex:indexPath.section] noise]];
break;
case 4:
cell.textLabel.text = @"Beacon";
cell.detailTextLabel.text = [NSString stringWithFormat:@"%d", [[self.s.signals objectAtIndex:indexPath.section] beacon]];
break;
default:
break;
}
return cell;
}
#pragma mark - Table view delegate
- (NSIndexPath*)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
return nil;
}
@end