【发布时间】:2015-04-20 03:00:39
【问题描述】:
我在使用 dispatch_async 方法来使用 AsyncSocket 时有点困惑。 这是我的代码
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
_socket = [[AsyncSocket alloc] initWithDelegate:self];
[_socket connectToHost:@"192.168.1.122" onPort:9501 error:nil];
[self sendCurrentLocation];
});
我使用此代码进行连接,但它不起作用,事件- (void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err 未被调用。
有人知道为什么吗?谢谢。
附言原谅我的英语。
【问题讨论】:
标签: ios sockets asyncsocket dispatch-async