From c1e42a2f3e014a86730e0ed87b94d772fed2db95 Mon Sep 17 00:00:00 2001 From: Daniel Stolzenberg Date: Tue, 26 Oct 2010 14:11:47 +0200 Subject: [PATCH] refactored duplicated method copying implementation --- Foundation/CPKeyValueObserving.j | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/Foundation/CPKeyValueObserving.j b/Foundation/CPKeyValueObserving.j index 745e884be..005603b3b 100644 --- a/Foundation/CPKeyValueObserving.j +++ b/Foundation/CPKeyValueObserving.j @@ -254,8 +254,11 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld, kvoClass._replacedKeys = _replacedKeys; //copy in the methods from our model subclass - var methodList = _CPKVOModelSubclass.method_list, - count = methodList.length, + var methodList = _CPKVOModelSubclass.method_list; + if ([_targetObject isKindOfClass:[CPDictionary class]]) + methodList = methodList.concat(_CPKVOModelDictionarySubclass.method_list); + + var count = methodList.length, i = 0; for (; i < count; i++) @@ -264,19 +267,6 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld, class_addMethod(kvoClass, method_getName(method), method_getImplementation(method), ""); } - if ([_targetObject isKindOfClass:[CPDictionary class]]) - { - var methodList = _CPKVOModelDictionarySubclass.method_list, - count = methodList.length, - i = 0; - - for (; i < count; i++) - { - var method = methodList[i]; - class_addMethod(kvoClass, method_getName(method), method_getImplementation(method), ""); - } - } - _targetObject.isa = kvoClass; }