0
我試圖在iOS應用程序中使用GCDAsyncSocket。我一直在關注CocoaAsyncSocket的wiki中提供的所有步驟。下面是我在做什麼:嘗試在iOS 5.1上使用GCDAsyncSocket寫數據的錯誤
GCDAsyncSocket socket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
NSError *err = nil;
if (![socket connectToHost:@"192.168.0.129" onPort:2811 error:&err]) // Asynchronous!
{
// If there was an error, it's likely something like "already connected" or "no delegate set"
NSLog(@"I goofed: %@", err);
}
uint8_t buffer[2] = "1\n";
NSData *data = [NSData dataWithBytes: &buffer length: sizeof(buffer)];
[socket writeData:data withTimeout:10 tag:1];
我已經包含了太多的依賴構架:安全& CFNetwork的,幷包括在我的課各自的代表。我是否需要其他配置來使用它?
當我運行這個例子中,我得到這個錯誤:
[NSMallocBlock bytes]: unrecognized selector sent to instance 0x6b7abe0 'NSInvalidArgumentException', reason: '-[NSMallocBlock bytes]: unrecognized selector sent to instance 0x6b7abe0'
而且它發生在這條線GCDAsyncSocket.m的
const uint8_t *buffer = (const uint8_t *)[currentWrite->buffer bytes] + currentWrite->bytesDone;