I have a question about safely or properly converting an NSString
into types such as CGFloat
and NSInteger
, considering that these are simply wrapper types that Apple created to use different primitives depending on certain factors (e.g., NSInteger
is typedef
'd to int
on 32-bit architectures and long
on 64-bit architectures).
For example, I know I can use something like [ someString intValue ]
or [ someString longValue ]
, but how do I instead say that I want someString
to become an NSInteger
, allowing the precision of the underlying primitive to be chosen by the compiler? Saying something like NSInteger integer = [ someString intValue ]
would result in data loss if someString
was created from an NSInteger
on a 64-bit system, right? What's the best way to deal with this situation?