I had questions about how to use the Assert in a block?
For example:
[someObject postRequestWithBlock:^(BOOL succeeded, NSError *error) {
CFRunLoopRef runLoopRef = CFRunLoopGetCurrent();
CFRunLoopStop(runLoopRef);
GHAssertTrue(succeeded&&!error, @"faile");
}];
CFRunLoopRun();
It will have to send an asynchronous request . After it is completed, I need to Assert whether it is successful.
But it's going to crash!
How i should do?
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];
}