任何人都可以告诉我代码连接的原因
- (IBAction)connectBtn:(id)sender {
socket = [[AsyncSocket alloc] initWithDelegate: self];
[socket connectToHost: @"127.0.0.1" onPort: 4321 error: nil];
}
,以下代码在connecttohost
上崩溃- (void)viewDidLoad
{
socket = [[AsyncSocket alloc] initWithDelegate: self];
[super viewDidLoad];
}
- (IBAction)connectBtn:(id)sender {
[socket connectToHost: @"127.0.0.1" onPort: 4321 error: nil];
}
套接字在视图controller.h文件中定义
@interface ViewController : UIViewController{
AsyncSocket *socket;
}