When should I use static variables with primitive types?

Posted by Felipe Cypriano on Programmers See other posts from Programmers or by Felipe Cypriano
Published on 2011-11-25T13:50:43Z Indexed on 2011/11/25 18:03 UTC
Read the original article Hit count: 339

Filed under:
|
|

Recently I came across the question NSString: Why use static over literal? and in the comments arrived a new question.

In Objective-C there some "special" types that are just maps to C primitives. Like the NSInteger.

#if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
#else
typedef int NSInteger;
#endif

I know how to use the static keywords for objects but I don't understand the implications on C primitive types.

When should I use a static NSInteger x instead of NSInteger x? What happens with the memory in both cases?

© Programmers or respective owner

Related posts about c

    Related posts about ios