创建线程时候中断在创建线程那个地方了

iOS 码拜 9年前 (2015-05-06) 662次浏览 0个评论
 
- (void)startRemote
{
	NSThread *myThread = [[NSThread alloc]
                          initWithTarget:self selector:@selector(mThreadFunc) param:self];
    [myThread start];
}

-(void)mThreadFunc:(id)param
{
    //something to do
}

调试的时候中断到initWithTarget
提示Thread 1:Program received signal:“SIGABRT”

创建线程时候中断在创建线程那个地方了
不知道什么原因该用下边的方法启动线程就好了

- (void)startRemote
{
    /*
	myThread = [[NSThread alloc]
                initWithTarget:self selector:@selector(mThreadFunc:) param:self];
    [myThread start];
    */
    [NSThread detachNewThreadSelector:@selector(mThreadFunc:) toTarget:self withObject:self];
    
}

此贴也没人回复借此再发一问

    sockfd = socket(AF_INET,SOCK_STREAM,0);
    if (sockfd == -1) {
        return;
    }
    their_addr.sin_family = AF_INET;
    their_addr.sin_addr.s_addr = inet_addr(@"192.168.1.181");
    their_addr.sin_port = htons(8000);
    bzero(their_addr.sin_zero, 8);
    int conn = connect(sockfd, &their_addr, sizeof(struct sockaddr));
    if (conn == -1) {
        return;
    }

192.168.1.181:8000是我弄的一个网页
单步调试每次到最后检测到connect的返回值都是-1
是不是ios也需要像android那样加一个权限在配置文件中说明呢?

创建线程时候中断在创建线程那个地方了
网页,直接用NSURLRequest访问 更方便
创建线程时候中断在创建线程那个地方了
40分
1.   NSThread *myThread = [[NSThread alloc]
                          initWithTarget:self selector:@selector(mThreadFunc:) param:self];

    mThreadFunc后面忘了加冒号了.


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明创建线程时候中断在创建线程那个地方了
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!