Reputation: 371
I want to get the information about subviews
property of class UIView
:
objc_property_t property = class_getProperty([UIView class], "subviews");
But, it returns nil? I think it is so strange. Could someone explain this behavior to me?
Upvotes: 3
Views: 355
Reputation: 371
I just write a test code:
@interface Cat : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic) NSInteger age;
@property (nonatomic, readonly, copy) NSArray *subviews;
@end
It is ok. So Apple maybe be do so magic on it I guess.
Upvotes: 0
Reputation: 43330
Weird. If you use -valueForKey:
, it can clearly be shown to exist. This used to be a bug with the old LLVM clang compiler in Xcode 3.2.3, where properties in categories (yes, it is declared in a category on UIView) wouldn't get recognized by the runtime, and there was even a bug report filed here about it. I know recent versions of Xcode have been having trouble with categories of late...
Upvotes: 1