Created
June 16, 2011 14:09
-
-
Save jdewind/1029290 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void *kBindingContext = &kBindingContext; | |
@implementation MySlider | |
@synthesize requestModel; | |
@synthesize percent; | |
- (id)init { | |
if((self = [super init])) { | |
[requestModel addObserver:self forKeyPath:@"percentUploaded" options:0 context:kBindingContext]; | |
} | |
return self; | |
} | |
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { | |
if (context == kBindingContext) { | |
self.percent = self.requestModel.percentUploaded; | |
} else { | |
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; | |
} | |
} | |
- (void)dealloc { | |
[requestModel removeObserver:self forKeyPath:@"percentUploaded"]; | |
[requestModel release]; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment