设置中的线程错误?

时间:2012-01-08 20:34:17

标签: objective-c

我得到ErrorMessage:

Automatic Reference Counting Issue
Receiver type 'NSThread' for instance message does not declare a method with selector 'initWithTarget:selector:Object:'

代码:

NSThread *thread_Client = [[NSThread alloc] initWithTarget:self selector:@selector(myTcpClient:) Object:nil];

为什么......我错过了什么?

THX

1 个答案:

答案 0 :(得分:1)

错误消息实际上会告诉您这里缺少的内容。它说NSThread没有这样的选择器,这意味着你应该查看方法签名,因为你的问题几乎肯定存在(在你的情况下,它是)。

代码中的错误是选择器中的单词 Object 。方法签名不使用大写 O 。将其更改为小写,你会没事的:

// Method signatures are case sensitive, so:
// -initWithTarget:selector:Object: and -initWithTarget:selector:object are different methods
[[NSThread alloc] initWithTarget:self selector:@selector(myTcpClient:) object:nil];