NSString memory allocation
Working through Chapter 3 of Cocoa Programming for Mac OS X. Question: why can you do this
NSString *temp = @"this is a string";
and you don’t have to do this:
NSString *temp = [[NSString alloc] init];
temp = @"this is a string";

July 17th, 2006 at 3:18 pm
I found the answer to my own question. On page 405 of Stephen G. Kochan’s Programming in Objective-C, he writes, “Space for constant strings is allocated differently in memory than other objects. They have no reference counting mechanism because they can never be released.” An instance of
NSConstantStringis created.