gpt4 book ai didi

ios - 我应该避免使用 new 来初始化我的对象吗?

转载 作者:可可西里 更新时间:2023-11-01 05:41:27 24 4
gpt4 key购买 nike

<分区>

最近有人告诉我苹果不鼓励使用新的,谷歌的 iOS 编码标准也有这样的说法:

Do not invoke the NSObject class method new, nor override it in a subclass. Instead, use alloc and init methods to instantiate retained objects. Modern Objective-C code explicitly calls alloc and an init method to create and retain an object. As the new class method is rarely used, it makes reviewing code for correct memory management more difficult.

为什么它会使审查正确内存管理的代码变得更加困难?

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