ARC-popviewController/DismissViewController [英] ARC - popviewController/DismissViewController

查看:53
本文介绍了ARC-popviewController/DismissViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对ARC有一些疑问.

I have some doubts with the ARC.

在ARC中: 当通过使用dismissViewController/popViewController来关闭viewcontroller时,分配给它的内存会自动释放吗?

In ARC: When a viewcontroller is dismissed by using the dismissViewController/popViewController, Will it's allocated memory automatically get released?

当有一个异步NSURLConnection正在运行并且在该操作完成之前,viewcontroller被关闭了,将会发生什么?

What will happen when there is an asynchronous NSURLConnection is running and before that operation completed, viewcontroller got dismissed?

谢谢

推荐答案

关闭视图控制器(或将其弹出)时,如果您没有对它进行任何强力指针(该控制器保留在导航控制器或呈现视图控制器,因此创建和推送或呈现时通常不需要指向它的指针.

When you dismiss a view controller (or pop it), it will be deallocated if you didn't make any strong pointers to it (that controller is retained by the navigation controller, or the presenting view controller, so you usually don't need to have a pointer to it when you create it and push or present it).

如果在关闭控制器时正在执行NSURLConnection,并且该控制器是连接的委托(这是通常的情况),则只有在connectionDidFinishLoading或connectionDidFailWithError完成之前,控制器才会被释放.这是因为连接仍处于活动状态,并且具有指向其委托的强大指针.

If an NSURLConnection is in progress when you dismiss the controller, and that controller is the delegate of the connection (which is the usual case), then the controller will not be deallocated until connectionDidFinishLoading or connectionDidFailWithError is completed. This is because the connection is still alive, and it has a strong pointer to its delegate.

这篇关于ARC-popviewController/DismissViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆