objc的重载以及void指针?
@interface MyClass : NSObject{}
- (void)show;
@end
@implementation MyClass
- (void)show {
NSLog(@"MyClass");
}
@end
@interface MySubClass : MyClass
{}
@end
@implementation MySubClass
- (void)show {
NSLog(@"MySubClass");
}
@end
一个临时函数:
- (void)show:(void *)temp {
MyClass *mc = (MyClass *)temp;
[mc show];
}
在主函数中调用:
MySubClass *msc = [[MySubClass alloc] init];
void *temp = (void *)msc;
[self show:temp];
控制台的结果://MySubClass
不是很明白这段代码的意思?
王道征途泡泡系
10 years, 8 months ago