gpt4 book ai didi

ios - UIStoryboard() 中的 nil 和 NSBundle 有什么区别?

转载 作者:行者123 更新时间:2023-11-28 09:37:29 25 4
gpt4 key购买 nike

我已经看到这两个被大量使用,但我找不到区别是什么:

let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())

let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle:nil)

那么将 bundle 设置为 nilNSBundle.mainBundle() 有什么区别?

最佳答案

其实这两者没有区别。无论您指定 nil 还是 NSBundle.mainBundle() 都将引用主包。

The bundle containing the storyboard file and its related resources. If you specify nil, this method looks in the main bundle of the current application.

引用:UIStoryboard Class Reference

bundle: 参数将在您需要从除 mainBundle() 之外的另一个包访问信息时变得有用。例如,许多第三方库都附带了自己的包,用于打包该特定库使用的资源。因此,如果您想访问这些资源,您需要引用该 bundle 。

关于ios - UIStoryboard() 中的 nil 和 NSBundle 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33398308/

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