-
Notifications
You must be signed in to change notification settings - Fork 8
/
AddRemoveButtonsController.m
35 lines (28 loc) · 1.02 KB
/
AddRemoveButtonsController.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
#import "AddRemoveButtonsController.h"
enum {
AddButton = 0,
RemoveButton
};
@implementation ComBelkadanWebmailer_AddRemoveButtonsController
- (void)awakeFromNib {
[addButton addObserver:self forKeyPath:@"enabled" options:0 context:[ComBelkadanWebmailer_AddRemoveButtonsController class]];
[removeButton addObserver:self forKeyPath:@"enabled" options:0 context:[ComBelkadanWebmailer_AddRemoveButtonsController class]];
}
- (IBAction)segmentClicked:(NSSegmentedControl *)sender {
switch ([sender selectedSegment]) {
case AddButton:
[addButton performClick:sender];
break;
case RemoveButton:
[removeButton performClick:sender];
break;
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (context == [ComBelkadanWebmailer_AddRemoveButtonsController class]) {
[segmentedButtons setEnabled:[object isEnabled] forSegment:[object tag]];
} else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
@end