0

I am somewhat new to iPhone dev and I have been getting unrecognized selector when I call CFSocketConnectToAddress in this code. I think it might be something basic that I am doing wrong. Any idea?

this is the complete error I get.

NSInvalidArgumentException unrecognized selector sent to instance 0x3922170

0x3922170 is the calling class.

- (BOOL)connect

{ CFSocketRef mySocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM,IPPROTO_UDP, 0, socketCallback, NULL);

@try {
    CFDataRef data = (CFDataRef)[_netService addresses]; 
    CFSocketConnectToAddress(mySocket, data, 500);

}
@catch (NSException * e) {
    NSLog([e name]);
    NSLog([e reason]);
}


//char joke[] = "Why did the chicken cross the road?";
//CFSocketError err = CFSocketSendData(mySocket, joke, (strlen(joke)+1), 10);
return true;

}

void socketCallback ( CFSocketRef s, CFSocketCallBackType callbackType, CFDataRef address, const void *data, void *info) {

}

4

1 回答 1

0

该错误很难跟踪,因为 NSInvalidArgumentException 是此错误的奇怪错误消息。但问题是我还没有解决 NSNetService 并且地址数组是空的。如果您使用空地址数组调用 CFSocketCreate,您将收到该错误。

于 2010-04-26T20:11:06.780 回答