What is a good example to differentiate between fileprivate and private in Swift3

前端 未结 10 1121
醉梦人生
醉梦人生 2020-11-27 10:03

This article has been helpful in understanding the new access specifiers in Swift 3. It also gives some examples of different usages of fileprivate

10条回答
  •  伪装坚强ぢ
    2020-11-27 10:26

    Although @MartinR's and @StephenChen's answer are perfect, Swift 4 changes things a little bit.

    Private is now considered as private to a class in which it is declared and also to its extensions.

    FilePrivate is considered to be private in that file be it a class in which the variable is defined, it's extension, or any other classes defined in that same file.

提交回复
热议问题