The NSKeyValueCoding
protocol acts in different ways while looking up for methods and instance variables. In the first case, it will look up for the method's selector's name, while in the last, it will look up for the instance variable's name.
This can be done manually, as we can see in the following samples:
// Manual implementation of KVC setter for method. NSString *mySetterString = [@"set" stringByAppendingString:[myKeyString capitalizedString]]; [myObject performSelector:NSSelectorFromString(mySetterString) withObject:myValue]; // Manual implementation of KVC setter for instance variable. object_setInstanceVariable(myObject, myKeyString, myValue);
Since KVC can look up for setters and getters automatically, you might only be required to use the preceding approach by creating your own lookup path if you want to avoid NSKeyValueCoding
to find specified or ordinary methods and instance variables.