1. 输出结果是啥,会不会崩溃?
//MNPerson
@interface MNPerson : NSObject
@property (nonatomic, copy)NSString *name;
- (void)print;
@end
@implementation MNPerson
- (void)print{
NSLog(@"self.name = %@",self.name);
}
@end
---------------------------------------------------
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
id cls = [MNPerson class];
void *obj = &cls;
[(__bridge id)obj print];
}
---------------------------------------------------
打印结果:self.name = <ViewController: 0x7fe667608ae0>
考察内存分配
参考一道高级iOS面试题(runtime方向)
网友评论