ios - NSURLConnection为什么在请求结束之前不会被释放
伊谢尔伦
伊谢尔伦 2017-04-17 17:52:01
[iOS讨论组]

如题,

NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://www.sqlite.org/2016/sqlite-amalgamation-3120100.zip"]] delegate:self];
[conn start];

假设这种情况下,我用NSURLConnection请求一个比较啊的文件,为什么在这种情况下,在请求结束之前NSURLConnection不会被释放呢?此时没有任何对象强引用它

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(1)
伊谢尔伦

看看 start 的文档,call conn 的 start 方法时,会把这个 conn 加到一个 run loop 里去,这就是为什么它没被释放, run loop “引用”了它。

Causes the connection to begin loading data, if it has not already.
Calling this method is necessary only if you create a connection with the initWithRequest:delegate:startImmediately: method and provide false for the startImmediately parameter. If you don’t schedule the connection in a run loop or an operation queue before calling this method, the connection is scheduled in the current run loop in the default mode.
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号