2
當我瀏覽Cocoa Touch API時,可以找到一些在同一頭文件中與類別一起聲明的類,同一頭文件中的類和類擴展(類別)
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>
@property (readonly) NSUInteger count;
// and some other properties
@end
@interface NSArray (NSExtendedArray)
@property (readonly, copy) NSString *description;
// and some other properties
@end
現在我試圖做同樣的事情,我的同班同學,就像如下:
@interface ARCTextbook : NSObject
@property (nonatomic) NSInteger ID;
@property (nonatomic) NSString *name;
@end
@interface ARCTextbook (Student)
@property (nonatomic) NSInteger studentID;
@property (nonatomic, getter=isUsed) BOOL used; // Used by a student?
@end
然而,當我試圖訪問studentID
或used
財產,我得到了一個無法識別的選擇錯誤。我錯過了什麼?
乾杯。
您是否嘗試運行的代碼?我在運行時遇到無法識別的選擇器錯誤。 – Andree 2015-02-25 01:05:23
嗨,謝謝你的回答。我想沒有辦法解決這個問題,但使用關聯的對象! – Andree 2015-02-26 05:55:43