首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NSLog:线程错误

NSLog:线程错误
EN

Stack Overflow用户
提问于 2012-01-09 05:21:01
回答 1查看 326关注 0票数 0

NSLog中的错误:

代码语言:javascript
复制
*** -[NSThread initWithTarget:selector:object:]: target does not implement selector (*** -[Document myTcpClient])

代码:

代码语言:javascript
复制
-(void) myTcpStart: (NSButton*) button{   
    //need threads for the following
    thread_Client = [[NSThread alloc] initWithTarget:self selector:@selector(myTcpClient) object:nil];
    thread_Display = [[NSThread alloc] initWithTarget:self selector:@selector(displayData) object:nil];

    [thread_Client start];
    [thread_Display start];

    [textField1 setStringValue:@"waiting for threads to run"];
}


-(void) myTcpStop: (NSButton*) button{   
    //need threads for the following

    //[thread_Client cancel];
    //[thread_Display cancel];
}

-(void) displayData{
    while(1){   
        [textField1 setStringValue:[NSString stringWithFormat:@"%d %d %f", j, i, genValue]];
        j++;
    }
}

-(void) myTcpClien{
    //some code
}

头文件:

代码语言:javascript
复制
#import <Cocoa/Cocoa.h>

@interface Document : NSDocument
{
    NSTextField *textField1;
    int i;
    int j;
    double genValue;
    NSWindowController *bController;
    NSThread *thread_Client;
    NSThread *thread_Display;
}

-(void) myTcpClient;
-(void) displayData;

-(void) myTcpStart: (NSButton*) button;
-(void) myTcpStop: (NSButton*) button;

@end
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-09 05:29:20

您在myTcpClient实现中忘记了T。同样,当您看到这些消息时,请检查您的代码是否存在拼写错误。

更改:

代码语言:javascript
复制
- (void)myTcpClien { /* ... */ }

至:

代码语言:javascript
复制
- (void)myTcpClient { /* ... */ }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8781436

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档