-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUITableAlertDataSource.m
58 lines (41 loc) · 1.25 KB
/
UITableAlertDataSource.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
//
// UITableAlertDataSource.m
// UIAlert-EmbeddedTable
//
// Created by Skylar Cantu on 10/10/09.
// Copyright 2009 Skylar Cantu. All rights reserved.
//
#import "UITableAlertDataSource.h"
@implementation UITableAlertDataSource
@synthesize data = _data;
- (id)initWithArray:(NSMutableArray *)array {
if (self = [super init]) {
self.data = [array mutableCopy];
}
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [_data count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return nil;
}
- (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] autorelease];
}
switch (indexPath.section) {
case 0:
cell.textLabel.text = [_data objectAtIndex:indexPath.row];
break;
default:
break;
}
return cell;
}
@end