我需要释放使用@"..."生成的NSString吗? [英] Do I need to release NSString generated using @"..."?

查看:71
本文介绍了我需要释放使用@"..."生成的NSString吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用以下代码制作NSString,是否需要释放someString?

If I make an NSString using the code below, do I need to need to release someString?

NSString *someString = @"somestring";

推荐答案

否,这是一个编译时常量字符串对象,因此不需要释放.这是char * c ="hello world"的道德对等物-字符串hello world位于全局数据中,并且您正在将此数据的地址分配给指针c.

No, it's a compile time constant string object, so it doesn't need releasing. It's the moral equiv of char *c = "hello world" -- where the string hello world is in global data, and you're assigning the address of this data to the pointer c.

这篇关于我需要释放使用@"..."生成的NSString吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆