ios编程时常见问题总结

来源:互联网 发布:c语言!=是什么意思 编辑:程序博客网 时间:2024/04/27 19:08

(1)在UIViewController里面使用了timer,会使得controller被retain,因此在viewdisapper时应将timer置为nil,否则controller的dealloc不会被执行。

 

(2)如果在UIViewController里面使用ASIHttprequest发送了async请求,并且将request的delegate设置为controller,若请求没回来时就销毁了controller,会使得request的delegate变为野指针,解决方案是:销毁controller时,调用request的cancel来取消请求,或者将request的delegate设置为nil。

      另外一种应对delegate变为野指针的方法是,假设delegate的类是A ,若object_getClass(delegate) != [A class] 说明是野指针了,此时就不能对delegate调用函数了。

0 0
原创粉丝点击