gpt4 book ai didi

objective-c - 我应该在 Objective C 类中的什么位置设置默认变量值

转载 作者:塔克拉玛干 更新时间:2023-11-01 19:14:22 24 4
gpt4 key购买 nike

我不能在头文件中设置默认值,那么应该在哪里设置呢?在类的指定初始化程序中?

最佳答案

是的,如果您需要特定的值,请使用类似init 的方法。这是推荐的方式。

The designated initializer is the method in each class that guarantees inherited instance variables are initialized (by sending a message to super to perform an inherited method). It’s also the method that does most of the work, and the one that other initialization methods in the same class invoke. It’s a Cocoa convention that the designated initializer is always the method that allows the most freedom to determine the character of a new instance (usually this is the one with the most parameters, but not always).

关于objective-c - 我应该在 Objective C 类中的什么位置设置默认变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7443799/

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