推荐答案
否,
No, you do not need class prefixes in Swift, because classes are namespaced to the module in which they live.
如果您需要区分(例如)Swift中的Array
和应用程序中声明的Array
类/结构,可以通过将其键入为Swift.Array
或MyProject.Array
.也可以使用扩展名:
If you need to disambiguate between (for example) an Array
from Swift and an Array
class/struct that you've declared in your app, you can do so by typing it as a Swift.Array
or a MyProject.Array
. That works with extensions as well:
extension Swift.Array {
...
}
extension MyProject.Array {
...
}
这篇关于Swift:需要类前缀吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!