Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c CocoaAsyncSocket在连接时崩溃_Objective C_Ios_Sockets_Ios5_Gcdasyncsocket - Fatal编程技术网

Objective c CocoaAsyncSocket在连接时崩溃

Objective c CocoaAsyncSocket在连接时崩溃,objective-c,ios,sockets,ios5,gcdasyncsocket,Objective C,Ios,Sockets,Ios5,Gcdasyncsocket,我在一个单独的类商店中分离了我的网络代码。代码非常简单,基于提供的示例: #import <UIKit/UIKit.h> #import "GCDAsyncSocket.h" @interface IBStore : UIViewController { GCDAsyncSocket *socket; } - (void)connect; - (void)socket:(GCDAsyncSocket *)sender didConnectToHost:(NSString *

我在一个单独的类商店中分离了我的网络代码。代码非常简单,基于提供的示例:

#import <UIKit/UIKit.h>
#import "GCDAsyncSocket.h"

@interface IBStore : UIViewController
{
    GCDAsyncSocket *socket;
}
- (void)connect;
- (void)socket:(GCDAsyncSocket *)sender didConnectToHost:(NSString *)host port:(UInt16)port;
- (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag;
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag;
@end
以下是从主视图控制器实例化IBStore的方式:

- (IBAction)connect:(id)sender {
    IBStore *client = [[IBStore alloc]init];
    [client connect];
}
不幸的是,应用程序没有执行
didConnectToHost
,而是在执行
socket4FD=socket(AF_INET,SOCK_STREAM,0)时在GCDAsyncSocket.m中崩溃(挂起)


任何关于为什么会发生这种情况的想法都将不胜感激。谢谢大家!

我的错误是在
connect
方法中声明和实例化IBStore类。现在,我已经将IBStore*client声明为实例变量,它工作得非常好。

尝试查找有关BSD套接字和挂起的更多信息。。。据我所知,它不应该挂在那里,所以有些奇怪的事情正在发生。下面是有关该函数的一些信息:
- (IBAction)connect:(id)sender {
    IBStore *client = [[IBStore alloc]init];
    [client connect];
}