I was wondering if there is a technical limitation on why the Foundation Framework couldn't implement a method that would implement -(void)encodeFloat:forKey:, -(void)encodeDouble:forKey:... etc. iterating through all of the ivars in a given class, using the default KVC values as the keys and picking the appropriate encoding methods based on the corresponding variable types. It seems like this would be the standard desired behavior in many cases, would shorten the amount of code (likely by several lines) for each class that implements it, would make code more maintainable, would prevent errors due to typos in keys (which are a pain), and would still allow for the programmer to implement different behavior using the existing methods if they needed to implement something more customized.
I'm seeing lots of advantages, and no real disadvantages, so I was wondering if it's such a great idea, why it's not there already. I doubt I'm the first person to conceive of such a method, and the fact that it doesn't exist leads me to believe there is probably a good technical reason why this isn't worth the trouble (or is actually somehow impossible).
I'm seeing lots of advantages, and no real disadvantages, so I was wondering if it's such a great idea, why it's not there already. I doubt I'm the first person to conceive of such a method, and the fact that it doesn't exist leads me to believe there is probably a good technical reason why this isn't worth the trouble (or is actually somehow impossible).