swift
fileprivate > 只限這個swift的檔案裡面存取,其他”檔案“無法存取,無法跨檔案。
private > 只限這個swift 檔案裡面所定義的 class存取。
class xxx{ private let xxx : String (只限在這裡面的class存取) }
以下寫得較詳細
- private: Visible just within the class.
-
private(set):Visible just set within the class.
- fileprivate: Visible from anywhere in the same file.
- internal: Visible from anywhere in the same module or app.
- public: Visible anywhere outside the module.
There are additional access control related keywords:
- open: Not only can it be used anywhere outside the module but also can be subclassed or overridden from outside.
- final: Cannot be overridden or subclassed.
ref: