Can anyone tell me why the code connects
- (IBAction)connectBtn:(id)sender {
socket = [[AsyncSocket alloc] initWithDelegate: self];
[socket connectToHost: @"127.0.0.1" onPort: 4321 error: nil];
}
and the code below crashes on connecttohost
- (void)viewDidLoad
{
socket = [[AsyncSocket alloc] initWithDelegate: self];
[super viewDidLoad];
}
- (IBAction)connectBtn:(id)sender {
[socket connectToHost: @"127.0.0.1" onPort: 4321 error: nil];
}
the socket is defined in view controller.h file
@interface ViewController : UIViewController{
AsyncSocket *socket;
}