enabled subclasses of CPSet to use CPObjects "addObserver:/removeObserver:" methods without throwing exception

This commit is contained in:
Daniel Stolzenberg committed 2010-10-27 12:35:50 +02:00
1 parent c1fd31fa23
commit dfba974572
1 file changed
+9 -3
+9 -3
View File
@@ -529,12 +529,18 @@ kvoOperators["sum"] = function sumOperator(self, _cmd, param)
- (void)addObserver:(id)observer forKeyPath:(CPString)aKeyPath options:(unsigned)options context:(id)context
{
[CPException raise:@"CPKeyValueObservingException" reason:@"CPSet is not key-value observable"];
if ([isa instanceMethodForSelector:_cmd] === [CPSet instanceMethodForSelector:_cmd])
[CPException raise:CPInvalidArgumentException reason:"Unsupported method on CPSet"];
else
[super addObserver:observer forKeyPath:aKeyPath options:options context:context];
}
- (void)removeObserver:(id)observer forKeyPath:(CPString)aKeyPath
-(void)removeObserver:(id)observer forKeyPath:(CPString)aKeyPath
{
[CPException raise:@"CPKeyValueObservingException" reason:@"CPSet is not key-value observable"];
if ([isa instanceMethodForSelector:_cmd] === [CPSet instanceMethodForSelector:_cmd])
[CPException raise:CPInvalidArgumentException reason:"Unsupported method on CPSet"];
else
[super removeObserver:observer forKeyPath:aKeyPath];
}
@end