If it helps, I can post more code.
Code:
- (void)initializeMyController
{
myController = [[MyController alloc] init];
NSArray *allValues = [NSArray arrayWithObjects:@"aKey", @"anotherKey" ,nil];
for(int i=0; i<[allValues count]; i++)
{
[myController addObserver:self
forKeyPath:[allValues objectAtIndex:i]
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:nil];
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
NSArray *allValues = [NSArray arrayWithObjects:@"aKey",@"anotherKey",nil];
if([allValues containsObject:keyPath])
{
[currentSelection updateDataFromDictionary:change];
}
[super observeValueForKeyPath:keyPath
ofObject:object
change:change
context:context];
}
MyController: has properties named aKey and anotherKey as floats, bound to textfields on a window. (thinking back, this is probably better descried as a model class)
currentSelection: Another controller class that takes the data in a dictionary and updates both model and view objects
self: has references to currentSelection and myController. It is basically the "main" Class (it has references to many controllers, but few models and views)
I know, I know, my MVC is a little twisted. But that shouldn't interfere with my KVC!!!
Help would be very much appreciated