I'm trying to use GCDAsyncSocket in my iOS app. I've been following all the step provided in the CocoaAsyncSocket's wiki. Here is what I'm doing:
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];
I already included too frameworks dependences: Security & CFNetwork, and included in my class the respective delegate. Do I need any other configuration to use it?
When I run this example I get this error:
[NSMallocBlock bytes]: unrecognized selector sent to instance 0x6b7abe0 'NSInvalidArgumentException', reason: '-[NSMallocBlock bytes]: unrecognized selector sent to instance 0x6b7abe0'
And it occurs on this line of GCDAsyncSocket.m
const uint8_t *buffer = (const uint8_t *)[currentWrite->buffer bytes] + currentWrite->bytesDone;