If I use this to set up NSData then the writeData method crashes.
NSString *test = @"The quick brown fox jumped over the lazy dog\r\n";
NSData *data = [test dataUsingEncoding:NSUTF8StringEncoding];
[asyncSocket writeData:data withTimeout:10 tag:4];
However if I use this one then it works… but I need the NSString so I can enter a formatted string to send…
char bytes[] = "The quick brown fox jumped over the lazy dog\r\n";
NSData* data = [[NSData alloc] initWithBytes:bytes length:sizeof(bytes)];
[asyncSocket writeData:data withTimeout:10 tag:4];
So what did I do wrong?
The NSString and the NSDate were not setup with alloc and init so they were gone when they got to the write data. I changed the NSDate to alloc and init and all works well now. These idea came from the several people that answered this. thanks for the help!