gpt4 book ai didi

swift - "public"在 Swift 中是什么意思?

转载 作者:行者123 更新时间:2023-11-28 06:50:45 25 4
gpt4 key购买 nike

我理解 internal 意味着该属性只能被 Swift 代码访问,而 private 意味着该属性只能被该文件访问,但不public 基本上与 internal 意思相同吗?除了 Swift 脚本之外还有什么想要访问该属性?

最佳答案

Public access enables entities to be used within any source file from their defining module, and also in a source file from another module that imports the defining module. You typically use public access when specifying the public interface to a framework.

Internal access enables entities to be used within any source file from their defining module, but not in any source file outside of that module. You typically use internal access when defining an app’s or a framework’s internal structure.

Private access restricts the use of an entity to its own defining source file. Use private access to hide the implementation details of a specific piece of functionality.

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html

关于swift - "public"在 Swift 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34984409/

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