我有一個數據模型,Objective-C的變量,它是與此類似:有多個權限
(in another project)
________________________________ _______________________
| | | |
| Graph | | DetailedGraph |
| GraphListener lstnr | | (needs to access foo) |
| NSString foo | <----|_______________________|
| ____________________________ |
| | GraphListener | | _______________________
| | Graph enclosing | | | |
| | (also needs to access foo) | | | OtherClass |
| |____________________________| | | (cannot access foo) |
|________________________________| |_______________________|
現在,我的問題是,GraphListener應該是一個內部類,不能在objc完成,所以我有這樣的解決方案:
@interface Graph_Listener
{
@private
Graph *enclosing;
}
@end
@interface Graph
{
@package
NSString *foo;
}
@end
現在,我的問題是,當我來繼承Graph
,並使DetailedGraph
類,這是在另一個項目,仍然需要訪問foo
,我怎麼能做到(我寧願不使用屬性,因爲變量foo
不應在GraphListener
和DetailedGraph
之外訪問。
有沒有什麼辦法來'隱藏'的屬性,所以他們只在我的項目中可見? – 2010-11-01 13:00:54
我已經決定讓它們公開,並且如果它們被修改就會產生後果。 – 2010-11-03 13:54:06