ARC下的stringWithFormat与initWithFormat [英] stringWithFormat vs initWithFormat under ARC
本文介绍了ARC下的stringWithFormat与initWithFormat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
stringWithFormat:
是NSString
的类方法,并返回自动释放的字符串; initWithFormat:
是一个实例方法,在ARC之前,程序员必须照顾返回对象的内存管理.如果打开了ARC,这两种方法有什么区别?
stringWithFormat:
is a class method of NSString
, and returns an autoreleased string; initWithFormat:
is an instance method, and before ARC the programmer had to take care of the returned object's memory management. If we have ARC turned on, what is the difference between the two methods?
推荐答案
使用ARC,这两种方法是等效的.
With ARC, these two methods are equivalent.
请参阅:
- WWDC 2011会议视频-介绍自动参考 计数
- WWDC 2011会议视频-Objective-C的进步 深入(说明ARC代码的编译方式)
- WWDC 2011 Session Video - Introducing Automatic Reference Counting
- WWDC 2011 Session Video - Objective-C Advancements In-Depth (explains how ARC code compiles)
这篇关于ARC下的stringWithFormat与initWithFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文