Objective C is not a pure Object-Orientated language, which means you often need to convert between primitive/basic types (like char or int) and objects (like NSValue or NSNumber). This is usually rather tedious and results in large amounts of boilerplate code.
This is especially true when dealing with dictionaries – dictionaries only accept objects which means all primitive types must be boxed and unboxed. I was pleased to discover that there is a nice shorthand when dealing with these situations.
For example, the following 2 lines are equivalent.
Apart from wrapping an expression (as I’ve done) there is a whole list of literals available with NSNumber:
There are also literals available with arrays and dictionaries:
While it still feels a bit clunky (especially if you’re coming from a pure object-orientated language like Ruby), it certainly makes things easier. Happy coding.