|
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
|
//
// EMCompoundResourceCell.m
// Compound Example
//
// Created by Dexter Weiss on 12/17/13.
// Copyright (c) 2013 Emmoco. All rights reserved.
//
#import "EMCompoundResourceCell.h"
@interface EMCompoundResourceCell () <UITextFieldDelegate> {
IBOutlet UITextField *_labelField;
IBOutlet UITextField *_valueField;
}
@end
@implementation EMCompoundResourceCell
-(void)setCompoundResourceValue:(NSDictionary *)compoundResourceValue {
[self willChangeValueForKey:@"compoundResourceValue"];
_compoundResourceValue = compoundResourceValue;
[self didChangeValueForKey:@"compoundResourceValue"];
[self _layout];
}
-(void)_layout {
[_labelField setText:[[self compoundResourceValue] objectForKey:@"label"]];
NSNumber *numberValue = [[self compoundResourceValue] objectForKey:@"value"];
[_valueField setText:[NSString stringWithFormat:@"%d", [numberValue integerValue]]];
}
#pragma mark - Text Field Delegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
NSDictionary *value = @{@"label" : [_labelField text],
@"value" : [_valueField text]};
[[self delegate] cellDidProcessEditing:value forIndex:[self index]];
return YES;
}
@end
|