I would appreciate some feedback on the specific approach I'm going to use. The following is a script.
I have an object (you can call it MObject), which has a number of properties, say, x and y coordinates, height and width. Properties are named according to KVC guidelines (MObject.x; MObject.height, etc.). My next task is to read in the XML file that this MObject describes. Unfortunately, XML elements are called differently - X and Y, Height and Width (note the capital letters).
Ideally, the XML elements will match the properties of the MObject. In this case, I could use KVC and avoid the whole code:
for (xmlProperty in xmlElement) { [MObject setValue:xmlProperty.value forKey:xmlProperty.name]. }
One way to approach this would be to use case-insensitive keys. Where to begin? Are there any other better solutions?
Suggestions are greatly appreciated.
design cocoa key-value-observing key-value-coding
Eightyight
source share