您的位置:首页 > 移动开发 > IOS开发

XCode 内置了 OCUnit 单元测试框架,但目前最好用的测试框架应该是 GHUnit。通过 GHUnit + OCMock 组合,我们可以在 iOS 下进行较强大的单元测试功能。本文将演示如何在

2014-10-09 22:31 1006 查看
在iOS SDK 5.0中使用ARC之后,有些东西咱们还是得在对象销毁的时候做,比如说注销Observer什么的,这个时候还是得重写dealloc方法。但是调用[super dealloc]时系统会提示ARC forbids
explicit message send of ‘dealloc’,怎么办呢?

根据苹果官方文档(https://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html)的精神,我们无需在重写的dealloc中添加[super dealloc],因为sdk在编译的时候会自己添加上去。

官方文档相关描述如下:

You may implement a
dealloc
method if you need
to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke
[systemClassInstance
setDelegate:nil]
on system classes and other code that isn’t compiled using ARC.

Custom
dealloc
methods in ARC do not require a
call to
[super dealloc]
(it actually results in
a compiler error). The chaining to super is automated and enforced by the compiler.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐