What is the right code pattern for NSNumberFormatter?
There are many example on the Internet (including this one: http://mac-objective-c.blogspot.com/2009/04/nsnumberformatter-some-examples.html) where the NSNumberFormatter is allocated and initialized each time it is needed.
Yet some other examples in the Apple Documentation (including International Mountains) prefer to use it as a private property. Another example (Locations) use it through a static variable.
How do you use an NSNumberFormatter? What is the most efficient technique?
NSNumberFormatteris not an excessively complicated object, so unless you’re using it frequently in a tight loop, efficiency doesn’t really matter.With that said, I’d tend to default to keeping it around in a static variable, if you’re trying to minimize the number of instances you create.