检查 xcode 中的指定初始值设定项 [英] Check designated initializer in xcode

查看:46
本文介绍了检查 xcode 中的指定初始值设定项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以找出Xcode中超类中指定的初始化程序?
我输入 super().init.. 然后,Xcode 显示超类的所有初始值设定项.我想知道是否有任何标志或符号可以指出哪个是指定的?

Is there any way to find out which initializer is the designated one in super class in Xcode?
I type super().init.. then, Xcode shows all initializers of superclass. I want to know is there any sign or symbol to point out which is the designated one?

也是一个简单的问题.子类中的指定构造器(DI)只能调用超类中的便利构造器(CI),因为超类中的 CI 最终会调用超类中的 DI.如果我错了,请纠正我,谢谢.

Also a quick question. A designated initializer(DI) in subclass is allowed to only call a convenience initializer(CI) in superclass since the CI in superclass will eventually call the DI in superclass. Correct me if I'm wrong, thanks.

推荐答案

在 Swift 中,任何没有用关键字convenience"标记的初始化器都是指定的初始化器.

In Swift, any initializer not marked with the keyword "convenience" is a designated initializer.

根据Swift 编程语言.他们不能调用便利初始化程序.

And designated initializers are required to call a designated initializer in their immediate superclass, per The Swift Programming Language. They cannot call a convenience initializer.

这篇关于检查 xcode 中的指定初始值设定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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