What is the right choice between NSDecimal, NSDecimalNumber, CFNumber?

If you are dealing with financial computations, you really should use base-10 arithmetic to avoid the rounding errors that can occur with the standard base-2 floating point types. So it’s either NSDecimal or NSDecimalNumber. And since you’re writing object-oriented code, NSDecimalNumber is the right choice for you. To answer your questions: only testing of your … Read more

How do you tell if a key exists for an object using Key-Value Coding?

If you are creating the object that is being checked, you could override valueForUndefinedKey: and setValue:forUndefinedKey to do something more useful than raising an exception. If, on the other hand, you are trying to introspect objects you don’t know about at runtime, you will have to use the runtime methods to do that. You can … Read more

Observing an NSMutableArray for insertion/removal

But shouldn’t the synthesized accessors automatically return such a proxy object? No. What’s the proper way to work around this–should I write a custom accessor that just invokes [super mutableArrayValueForKey…]? No. Implement the array accessors. When you call these, KVO will post the appropriate notifications automatically. So all you have to do is: [myObject insertObject:newObject … Read more