鉴于这种代码:@“某些文本”是否给出自动释放或保留1个对象?
// Initialize string
NSString *name = @"Franzi";
@“”宏创建与给定的文本(这里的名称弗兰西)和1一个保留计数一个的NSString?
所以@“”给出了一个NSString必须被释放吗?我负责这个对象吗? 第二个代码示例则混淆了我,即使我用这种方式:
NSSting *message;
message = [NSString stringWithFormat:@"Hello @%!",name];
//message = [NSString stringWithFormat:@"Hello Girl!"];
所以消息被在接下来的运行循环,K释放。但是,作为stringWithFormat参数提供的NSString是什么?
请问类对象NSString是否释放NSString @“Hello%@”/ @“Hello Girl”作为参数? 还是@“” - Konstruktor只回馈自动发布的NSStrings?
关于常量/字符串堆栈溢出的一些其他问题:[1](http://stackoverflow.com/questions/1390334/nsstring-retain-count)[2](http://stackoverflow.com/问题/ 2768443/where-are-constant-nsstrings-allocated)[3](http://stackoverflow.com/questions/4804943/difference-bewteen-declaring-a-nsstring-with-alloc-and-init-and-分配 - )[4](http://stackoverflow.com/questions/2014667/memory-management-in-objective-c)[5](http://stackoverflow.com/questions/1320161/is-string-编译器优化编译) – 2011-05-20 09:04:53
'@“”'不是一个宏,而是一个Objective-C字符串文字。 – 2011-05-20 09:07:01