/
QPickerElement.m
52 lines (42 loc) · 1.26 KB
/
QPickerElement.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
#import "QPickerElement.h"
#import "QPickerTableViewCell.h"
#import "QPickerWhitespaceDelimitedStringParser.h"
@implementation QPickerElement
{
@private
NSArray *_items;
void (^_onValueChanged)();
}
@synthesize items = _items;
@synthesize valueParser = _valueParser;
@synthesize onValueChanged = _onValueChanged;
- (QPickerElement *)init {
self = [super init];
self.valueParser = [QPickerWhitespaceDelimitedStringParser new];
return self;
}
- (QPickerElement *)initWithTitle:(NSString *)title items:(NSArray *)items value:(id)value
{
if ((self = [super initWithTitle:title Value:value])) {
_items = items;
self.valueParser = [QPickerWhitespaceDelimitedStringParser new];
}
return self;
}
- (UITableViewCell *)getCellForTableView:(QuickDialogTableView *)tableView controller:(QuickDialogController *)controller
{
QPickerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:QPickerTableViewCellIdentifier];
if (cell == nil) {
cell = [[QPickerTableViewCell alloc] init];
}
[cell prepareForElement:self inTableView:tableView];
cell.imageView.image = self.image;
return cell;
}
- (void)fetchValueIntoObject:(id)obj
{
if (_key != nil) {
[obj setValue:_value forKey:_key];
}
}
@end