#import <objc/runtime.h>
@interface MacBook : NSObject
@property (nonatomic) NSString *name;
- (void)restart;
@end
@implementation MacBook
- (void)restart {
}
@end
//show methods
unsigned int count;
Method *methods = class_copyMethodList(
[MacBook class], &count);
for (unsigned int i = 0; i < count; i++) {
SEL sel = method_getName(methods[i]);
NSLog(@"%@", NSStringFromSelector(sel));
}
free(methods);
//show instance variables
Ivar *ivars = class_copyIvarList(
[MacBook class], &count);
for (unsigned int i = 0; i < count; i++) {
NSLog(@"%s", ivar_getName(ivars[i]));
}
free(ivars);