"public"在Swift中是什么意思?
What does "public" mean in Swift?
我理解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.
Public 可以在该模块的任何地方访问,并且可以在实现该模块的另一个模块的源代码中访问(即导入带有 public 变量的文件允许导入器访问 public 变量,但不是内部或私有变量)
我理解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.
Public 可以在该模块的任何地方访问,并且可以在实现该模块的另一个模块的源代码中访问(即导入带有 public 变量的文件允许导入器访问 public 变量,但不是内部或私有变量)