implemented "will/didChangeValueForKey:withSetMutation:usingObjects:" in _CPKVOModelSubclass in CPKeyValueObserving.j

This commit is contained in:
Daniel Stolzenberg committed 2010-10-26 14:17:39 +02:00
1 parent a2ff814796
commit 5ff7e66981
1 file changed
+45
+45
View File
@@ -597,6 +597,51 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
[[_CPKVOProxy proxyForObject:self] _sendNotificationsForKey:aKey changeOptions:nil isBefore:NO];
}
- (void)willChangeValueForKey:(CPString)aKey withSetMutation:(CPKeyValueSetMutationKind)mutationKind usingObjects:(CPSet)objects
{
var superClass = [self class],
methodSelector = @selector(willChangeValueForKey:withSetMutation:usingObjects:),
methodImp = class_getMethodImplementation(superClass, methodSelector);
methodImp(self, methodSelector, aKey, mutationKind, objects);
if (!aKey)
return;
var changeOptions = [CPDictionary dictionary];
switch(mutationKind)
{
case CPKeyValueUnionSetMutation:
[changeOptions setObject:CPKeyValueChangeInsertion forKey:CPKeyValueChangeKindKey];
break;
case CPKeyValueMinusSetMutation:
[changeOptions setObject:CPKeyValueChangeRemoval forKey:CPKeyValueChangeKindKey];
break;
case CPKeyValueIntersectSetMutation:
[changeOptions setObject:CPKeyValueChangeRemoval forKey:CPKeyValueChangeKindKey];
break;
case CPKeyValueSetSetMutation:
[changeOptions setObject:CPKeyValueChangeReplacement forKey:CPKeyValueChangeKindKey];
break;
}
//TO DO: find a way to specify "objects"
[[_CPKVOProxy proxyForObject:self] _sendNotificationsForKey:aKey changeOptions:changeOptions isBefore:YES];
}
- (void)didChangeValueForKey:(CPString)aKey withSetMutation:(CPKeyValueSetMutationKind)mutationKind usingObjects:(CPSet)objects
{
var superClass = [self class],
methodSelector = @selector(didChangeValueForKey:withSetMutation:usingObjects:),
methodImp = class_getMethodImplementation(superClass, methodSelector);
methodImp(self, methodSelector, aKey, mutationKind, objects);
if (!aKey)
return;
[[_CPKVOProxy proxyForObject:self] _sendNotificationsForKey:aKey changeOptions:nil isBefore:NO];
}
- (Class)class
{
return self[KVOProxyKey]._nativeClass;