0
我有关于如何在块中使用Assert的问题?如何在块中使用断言?
例如:
[someObject postRequestWithBlock:^(BOOL succeeded, NSError *error) {
CFRunLoopRef runLoopRef = CFRunLoopGetCurrent();
CFRunLoopStop(runLoopRef);
GHAssertTrue(succeeded&&!error, @"faile");
}];
CFRunLoopRun();
它必须发送的异步请求。 完成后,我需要声明它是否成功。
但它会崩溃!
我该怎么办?
thx!
PS: - (void)testCase { [self prepare];
__block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
__block typeof (&*self) bself = self;
[request setCompletionBlock:^{
[bself notify:kGHUnitWaitStatusSuccess forSelector:@selector(testCase)];
GHAssertTrue(YES, @"faile");
}];
[request setFailedBlock:^{
[bself notify:kGHUnitWaitStatusFailure forSelector:@selector(testCase)];
GHAssertTrue(NO, @"faile");
}];
[request startAsynchronous];
[self waitForStatus:kGHUnitWaitStatusCancelled timeout:15.0];
}
你不想断言完成是错误的,错误是真的吗?你有他们的另一种方式。 –