const vs static NSStrings in Objective-C

Viewed 13948

These lines are both in the implementation file above the @implementation declaration.

NSString * const aVar = @"aVarStringValue";

static NSString *aVar = @"aVarStringValue";

As far as I understand, the second static is allocated once only within the lifetime of the application and this fact contributes to performance.

But does this mean it is essentially a memory leak seeing as that block of memory will never be released?

And does the first const declaration get allocated every time it is accessed in contrast?

3 Answers
Related