gpt4 book ai didi

objective-c - ARC 下的 stringWithFormat 与 initWithFormat

转载 作者:太空狗 更新时间:2023-10-30 04:01:22 27 4
gpt4 key购买 nike

stringWithFormat:NSString的类方法,返回一个自动释放的字符串; initWithFormat: 是一个实例方法,在 ARC 之前,程序员必须负责返回对象的内存管理。如果我们打开了 ARC,这两种方法有什么区别?

最佳答案

启用 ARC 后,这两种方法是等效的(即 ARC 将自动调用 autorelease 方法;总是注册到最近的 @autoreleasepool).

参见:

关于objective-c - ARC 下的 stringWithFormat 与 initWithFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7960912/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com