cocoa – 字符串或带字符串的nsstring

cocoa – 字符串或带字符串的nsstring,第1张

概述让我们假设myProp是@property(保留)NSString * myProp并为我们合成…. self.myProp = @"some value";//string literal?self.myProp = [NSString stringWithString:@"some value"]; 这里有区别吗? 第一个字符串文字是不是自动释放的,还是只是在内存中它的当前范围,我不必担心 让我们假设myProp是@property(保留)Nsstring * myProp并为我们合成….

self.myProp = @"some value";//string literal?self.myProp = [Nsstring stringWithString:@"some value"];

这里有区别吗?
第一个字符串文字是不是自动释放的,还是只是在内存中它的当前范围,我不必担心它?

解决方法 你可能想花一些时间在 String Programming Guide.从链接部分(关于创建@“字符串常量”):

Such an object is created at compile time and exists throughout your program’s execution. The compiler makes such object constants unique on a per-module basis,and they’re never deallocated,though you can retain and release them as you do any other object.

总结

以上是内存溢出为你收集整理的cocoa – 字符串或带字符串的nsstring全部内容,希望文章能够帮你解决cocoa – 字符串或带字符串的nsstring所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1003607.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-22
下一篇2022-05-22

发表评论

登录后才能评论

评论列表(0条)

    保存