[問題] 有關object-c中的@property
我想請問
@interface myObject:NSObject {
NSString *name;
}
@property(readonly) NSString *name;
------------------------------------
@implementation
-(NSString*)name {
return ......
}
@end
究竟@property(readonly)是針對interface中name這個變數
還是implementation中name這個method?
因為根據我的試驗結果,@property好像只會在乎有沒有在@implementation被implemented
另外如果我將上述例子改寫為
@interface myObject:NSObject {
NSString *name;
}
@property(readonly) NSString *getName;
------------------------------------
@implementation
@synthesize getName;
@end
會發生什麼事情?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.146.39.13
※ 編輯: Gsus 來自: 122.146.39.13 (12/16 00:22)
※ 編輯: Gsus 來自: 122.146.39.13 (12/16 00:41)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章