title: Converting HEX NSString To NSData
body: <p>I'm trying to convert a Hex <code>NSString</code> to <code>NSData</code> (I'm using the below attached code). The following is the output:</p>
  
  <pre><code>&lt;00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000&gt;
  </code></pre>
  
  <p>which looks totally irrelevant to me. Any idea/ suggestions on where its going wrong? </p>
  
  <pre><code>NSString *strData = @"72ff63cea198b3edba8f7e0c23acc345050187a0cde5a9872cbab091ab73e553";
  
  NSLog(@"string Data length is %d",[strData length]);
  
  NSMutableData *commandToSend= [[NSMutableData alloc] init];
  unsigned char whole_byte;
  char byte_chars[2];
  int i;
  for (i=0; i &lt; [strData length]/2; i++) {
  
      byte_chars[0] = [strData characterAtIndex:i*2];
      byte_chars[1] = [strData characterAtIndex:i*2+1];
      whole_byte = strtol(byte_chars, NULL, [strData length]);
      [commandToSend appendBytes:&amp;whole_byte length:1]; 
  }
  NSLog(@"%@", commandToSend);    
  </code></pre>