[Swift学习] 访问控制 Access Control, private、public、filePrivate等修饰符

本文详细介绍了Swift中的访问控制级别,包括private, fileprivate, internal, public和open的使用场景和区别。文章还讨论了访问控制的原则,如不能用低级别访问权限的实体定义高级别实体,并且展示了如何通过访问控制修饰符来管理getter和setter的读写权限。" 111389688,10295753,FPGA在数字信号处理中的应用与优势,"['FPGA应用', '数字信号处理', '通信接口', '嵌入式系统', '并行计算']
摘要由CSDN通过智能技术生成

private , fileprivate,internal,public,open

从整体看,权限 private < fileprivate < internal < public < open

swift官方定义

Swift Access Control

Swift provides five different access levels for entities within your code. These access levels are relative to the source file in which an entity is defined, and also relative to the module that source file belongs to.

Open access and public access enable 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 open or public access when specifying the public interface to a framework. The difference between open and public access is described below.

Internal access enables entities to be

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值