[問題] 有關object-c中的@property

看板MacDev作者 (肉元,吉米,助教)時間15年前 (2009/12/16 00:14), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
我想請問 @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)
文章代碼(AID): #1B9xNqFY (MacDev)
文章代碼(AID): #1B9xNqFY (MacDev)