問題:
In Objective-C instance data can be public
, protected
or private
.在 Objective-C 實例數據可以是public
、 protected
或private
。 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?