0

谁能告诉我为什么代码连接

- (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];

 }

套接字在 view controller.h 文件中定义

 @interface ViewController : UIViewController{
 AsyncSocket *socket;

 }
4

0 回答 0