What does @() mean in Objective-C?
objective-c
Solution
It's a pointer to an `NSNumber` object. It's called a boxed literal, because the mental picture is of putting a primitive value of expression inside into a "box", that is, an object.
See official documentation if in doubt. Note that pointer can be to a "real" `NSNumber` object or it can (theoretically, don't know whether this will work in practice) be a tagged pointer (see, e.g., my question).
Note that you can also do things like `@"string"` and `@5`, which will create constants in compile time. But you need parentheses to use something which is not a literal, e.g. `@(2 + 3)`. Parentheses form can be used for any expression, even those that compiler cannot compute at compile-time (although if it can, it will just put an expression result into code).
Problem
For example, ``` CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation"]; [rotate setToValue:@(M_PI)]; [rotate setDuration:0.1f]; [[aView layer] addAnimation:rotate forKey:@"myRotationAnimation"]; ``` where `M_PI` is defined as a macro in `math.h`, ``` #define M_PI 3.14159265358979323846264338327950288 /* pi */ ```