I am receiving some byte data from server as defined in following method
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
\//04 01 00
NSString *string = [
[NSString alloc]
initWithData:data
encoding:NSASCIIStringEncoding
];
NSLog(string);
char *ptr = (void *)[data bytes]; // set a pointer to the beginning of your data bytes
if(*ptr == 0x06) {
NSLog(@"okay,.. got a 0x06");
}
ptr++; // go to the next byte
if(*ptr == 0x05) {
NSLog(@"okay,.. got a 0x05");
}
ptr++;
if(*ptr==0X00){
NSLog(@"okay,.. got a 0X00");
}
//04 01 00
NSString* newStr = [[NSString alloc] initWithData:data
encoding:NSASCIIStringEncoding];
///////////////////
///////////////////
NSLog(@"I received some thing , now trying to read it");
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Data Received" message:newStr delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
[alert release];
[sock readDataWithTimeout:-1 tag:0];
//NSLog(@"Reading %@",newStr);
}
I can compare the hexa values but not able to see in UIAlertView as I think I am not able to convert correctly , so please help how to convert in into NSString and in NSMutableArray so that I can use it dynamically