美文网首页
ios-runtime面试题

ios-runtime面试题

作者: 逆流瞅瞅 | 来源:发表于2019-12-14 21:15 被阅读0次
    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方向)

    相关文章

      网友评论

          本文标题:ios-runtime面试题

          本文链接:https://www.haomeiwen.com/subject/axzcnctx.html