可能重複:
Properties and Instance Variables in Objective-C 2.0
Objective-C Properties with or without instance variablesObjective C中的類聲明有什麼區別?
是什麼代碼下面兩段之間的區別?兩者都是可編譯的,我不知道哪一個是「正確的」。
@interface JTPlayer : NSObject {
NSString *userId;
NSString *name;
BOOL inBattle;
}
@property (nonatomic, copy) NSString *userId;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) BOOL inBattle;
@end
和
@interface JTPlayer : NSObject
@property (nonatomic, copy) NSString *userId;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, assign) BOOL inBattle;
@end
該死的,我輸入了一個答案,然後發現它是一個副本。 @Sergio,請有時候做一點努力:接受答案並使用搜索工具... – Kheldar