ChenYilong / iOSInterviewQuestions

iOS interview questions;iOS面试题集锦(附答案)--学习qq群或 Telegram 群交流 https://github.com/ChenYilong/iOSBlog/issues/21

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

第34题

deanyang506 opened this issue · comments

在viewDidLoad中创建的对象在viewDidAppear中释放掉,我复制了一份测试代码运行,发现结果不一样,即使在viewDidAppear对象还在并没被释放,还有就是

  • (void)viewDidLoad {
    [super viewDidLoad];
    @autoreleasepool {
    NSString *str = [NSString stringWithFormat:@"sunnyxx"];
    }
    NSLog(@"%@", str); // Console: (null)
    }
    这能访问的到str吗?错的好吧

总体来说和释放时机有出入,希望作者给出正确的答案