我如何知道指定的初始值设定项是哪个? [英] How do I know which initializer is the designated initializer?

查看:85
本文介绍了我如何知道指定的初始值设定项是哪个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么知道ANY类的指定初始化器是哪个?
我猜想它是参数最多的那个,但有时可能不正确。

How do I know which initializer is the designated initializer for ANY class? I'm guessing that it is the one that takes the most parameters, but there could be times where this is not correct.

推荐答案

omz的答案可以更明确地陈述:框架类的文档将指定哪个是指定的初始化程序。为了编写行为正确的子类,有必要知道指定的初始值设定项是什么。子类别的D.I.必须致电超类的D.I.为了确保正确初始化它。

omz's answer can be stated more firmly: The documentation for a framework class will specify which is the designated initializer. It's necessary to know what the designated initializer is in order to write subclasses that behave properly. The subclass's D.I. must call up to the superclass's D.I. in order to be sure that it is properly initialized.

但是,关于最大数量参数的猜测是有根据的。苹果实际上声称它通常是D.I.在一些地方。

Your guess about the greatest number of parameters is well-founded, however. Apple actually states that it is often the D.I. in a few places.

可可核心能力


带有初始化参数的完整补充的类通常是指定的初始化器。

The initializer of a class that takes the full complement of initialization parameters is usually the designated initializer.

可可基础知识


某些子类提供了方便的初始化程序,这些初始化程序将默认值提供给采用完整初始化参数补充的初始化程序。该初始化程序通常是指定的初始化程序,是类中最重要的初始化程序。

Some subclasses provide convenience initializers that supply default values to an initializer that takes the full complement of initialization parameters. This initializer is usually the designated initializer, the most important initializer of a class.

这篇关于我如何知道指定的初始值设定项是哪个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆