我使用这个小片段来停止模拟器中的iPhone应用程序。
NSAssert((0), @"Bail early while testing");
当我试图使它成为#定义的宏时,如下所示:
#define BAILNOW (NSAssert((0), @"Bail early while testing"))
我得到了这个构建错误:
错误:“do”之前的预期表达式
这似乎与NSAssert()宏的嵌套有关,但我不知道如何绕过它。我应该深入NSAssertionHandler文档,还是有更简单的方法来阻止应用程序在它的轨道?还是我应该设置一个断点继续我的生活?
BGLogin * login = [[BGLogin alloc]init];
[nav pushViewController:login animated:YES];
login.view; //access it once to trigger didload
NSAssert(login.navigationItem==login.navigationItemAtDidload,@"They should be the same");//View didload isn't called yet here.
NSAssert(login.navigationC
我用-Weverything编译了我的项目,我发现所有的NSAssert调用都有警告。
必须至少为“.”指定一个参数变元宏参数
NSAssert(NO, @"This class cannot be instantiated!");
正确的解决方法是在所有语句中添加一个nil参数,但我更愿意静默此警告。有可能吗?
干杯
我搞不懂为什么我会
use of undeclared identifier _cmd did you mean rcmd
在NSAssert所在的线路上。
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int x = 10;
NSAssert(x > 11, @"x should be greater tha
我刚刚开始为我的iOS应用程序编写测试,我正在使用Xcode4和OCUnit。我现在正在为一段代码编写一个测试,如果静态变量已经被赋值,它应该会抛出异常,如下所示:
NSAssert(controllerInstance == nil, @"another controller is already in use!");
在我的测试中,如果实例已经存在,我使用STAssertThrows检查上面的代码是否抛出错误。问题是这个测试失败了,原因是:
*** Assertion failure in (reference to row with NSAssert)
所以即使行为正是我