我有以下代码...
-(void) SetSerialNumber
{
NSLog(@"SetSerialNumber");
NSString *serialNum = textFieldSecond.text;
if (textFieldSecond.text == nil) {
[self performSelectorOnMainThread:@selector(display:) withObject:@"Please Enter the serial number" waitUntilDone:YES];
return;
}
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^(void){
NSString* response;
[self performSelectorOnMainThread:@selector(display:) withObject:@"Sending Set Serial Num request" waitUntilDone:YES];
[[testApp sharedClass] SetSerNumber:serialNum];
[self performSelectorOnMainThread:@selector(display:) withObject:@"Waiting for Response..." waitUntilDone:YES];
response = [[Process sharedProcess] readAndProcessData:ACK];
[self performSelectorOnMainThread:@selector(display:) withObject:rpcresponse waitUntilDone:YES];
});
}
该方法display:
将消息放在UITextView
.
我在按下按钮时调用此函数。有时 dispatch_async 块没有被调用。它只是通过它。但是,我每次都可以看到打印的日志消息。
任何人都可以分享可能导致这种情况的原因吗?