title: How do you convert NSData to NSString or char?
body: <p>I have an NSData instance containing &lt;7e0006b5 01012605 06070172 7a>, how can I convert it to an NSString containing @"7e0006b501012605060701727a"?</p>
  
  <p>My test code is:</p>
  
  <pre><code>char c_command[26] = {'7', 'e', '0', '0', 
                        '0', '6', 'b', '5', 
                        '0', '1', '0', '1', 
                        '2', '6', '0', '5', 
                        '0', '6', '0', '7', 
                        '0', '1', '7', '2', 
                        '7', 'a'};
  NSMutableData *commandToSend  = [[NSMutableData alloc] init];
  
  for (int i = 0; i &lt; 13; i++) {
      unsigned char data_byte;
      char byte_chars[3] = {'\0','\0','\0'};
      byte_chars[0] = c_command[i * 2];
      byte_chars[1] = c_command[i * 2 + 1];
      data_byte = strtol(byte_chars, NULL, 16);
      [commandToSend appendBytes:&amp;data_byte length:1];
  }
  NSString *str = [[NSString alloc] initWithData:commandToSend encoding:NSASCIIStringEncoding];
  NSLog(@"Test command is :%@ \n command to string is:%@", commandToSend, str);
  </code></pre>
  
  <p>the output of log is:</p>
  
  <pre><code>Test command is :&lt;7e0006b5 01012605 06070172 7a&gt; command to string is:~
  </code></pre>