objective-c - 关于iOS内存管理的问题
PHP中文网
PHP中文网 2017-04-18 09:40:57
0
1
395
@autoreleasepool {
    NSObject *obj = [[NSObject alloc] init];
}

以上代码在ARC模式下,obj对该对象有强引用,一旦出了这个作用域,强引用失效,对象被销毁。
同时该对象又被注册到autoreleasepool中,因为出了autoreleasepool的作用域,对象岂不是又要销毁一次???

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
刘奇

The scope of obj is the scope of the automatic release pool. It will not be used twice. After adding @autoreleasepool, the object is placed in the release pool

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!