Swift 有訪問修飾符嗎? - Does Swift have access modifiers?

問題:

In Objective-C instance data can be public , protected or private .在 Objective-C 實例數據可以是publicprotectedprivate For example:例如:

@interface Foo : NSObject
{
  @public
    int x;
  @protected:
    int y;
  @private:
    int z;
  }
-(int) apple;
-(int) pear;
-(int) banana;
@end

I haven't found any mention of access modifiers in the Swift reference.我在 Swift 參考中沒有發現任何提及訪問修飾符的內容。 Is it possible to limit the visibility of data in Swift?是否可以限制 Swift 中數據的可見性?


解決方案:

參考一: https://stackoom.com/question/1ciVy
參考二: Does Swift have access modifiers?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章