在 Swift 中,调用 UINavigationController() 和 UINavigationController.init() 有什么区别? [英] In Swift, what's the difference between calling UINavigationController() vs UINavigationController.init()?

查看:20
本文介绍了在 Swift 中,调用 UINavigationController() 和 UINavigationController.init() 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Swift 中,调用 UINavigation()UINavigation.init() 有什么区别?它们似乎都返回了 UINavigationController 的有效实例.

In Swift, what's the difference between calling UINavigation() vs UINavigation.init()? They both seem to return valid instance of UINavigationController.

推荐答案

UINavigationController()UINavigationController.init() 是完全一样的东西.您可以通过在 Playground 中输入两者然后 option-单击它们来验证这一点.两者都会调出同一个初始化程序的文档.

UINavigationController() and UINavigationController.init() are the exact same thing. You can verify this by typing both into a Playground and then option-clicking on them. Both bring up the documentation for the same initializer.

Swift 约定是只使用类型名称(没有 .init).

The Swift convention is to use just the type name (without .init).

这篇关于在 Swift 中,调用 UINavigationController() 和 UINavigationController.init() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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