diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index ed3a2eb22..7c30059a7 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -4,7 +4,7 @@ @import "CPController.j" -@implementation CPObjectController : CPController +@implementation CPObjectController : CPController { id _contentObject; id _selection; @@ -255,7 +255,7 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb id _keyPath; id _observer; id _object; - + BOOL _notifyObject; id _context; @@ -306,7 +306,7 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb if (anObject._observer === _observer && [anObject._keyPath isEqual:_keyPath] && [anObject._object isEqual:_object]) return YES; } - + return NO; } @@ -314,7 +314,7 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb { if (_notifyObject) [_object observeValueForKeyPath:_keyPath ofObject:_object change:change context:context]; - + [_observer observeValueForKeyPath:_keyPath ofObject:_object change:change context:context]; } @@ -334,7 +334,7 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb { var a = []; a.isa = self; - + var ivars = class_copyIvarList(self), count = ivars.length; @@ -349,6 +349,16 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb return "<_CPObservableArray: "+[super description]+" >"; } +- (id)initWithArray:(CPArray)anArray +{ + if (self = [super initWithArray:anArray]) + { + _observationProxies = []; + } + + return self; +} + - (id)initWithObjects:(CPArray)objects count:(unsigned)count { if (self = [super initWithObjects:objects count:count]) @@ -364,16 +374,16 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb if (aKeyPath.indexOf("@") === 0) { var proxy = [[_CPObservationProxy alloc] initWithKeyPath:aKeyPath observer:anObserver object:self]; - + proxy._options = options; proxy._context = context; - + [_observationProxies addObject:proxy]; - + var dotIndex = aKeyPath.indexOf("."), remaining = aKeyPath.substring(dotIndex+1), indexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self count])]; - + [self addObserver:proxy toObjectsAtIndexes:indexes forKeyPath:remaining options:options context:context]; } else @@ -422,7 +432,7 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb [self didChangeValueForKey:keyPath]; } - [self insertObject:anObject atIndex:anIndex]; + [super insertObject:anObject atIndex:anIndex]; } - (void)removeObjectAtIndex:(unsigned)anIndex @@ -458,7 +468,7 @@ var CPObjectControllerObjectClassNameKey = @"CPObjectControllerOb - (void)replaceObjectAtIndex:(unsigned)anIndex withObject:(id)anObject { var currentObject = [self objectAtIndex:anIndex]; - + for (var i=0, count=[_observationProxies count]; i