title: Little-Endian Byte Order (iOS, BLE scan response)
body: <p>In basic terms, I am using nativescript for a cross platform application. This application interacts with BLE devices. The BLE devices send a scan response after the advertisement packet, which I am able to retrieve as an NSData object on the iOS side.</p>
  
  <p>Here is the (pseudo) output from the description property: &lt;54fca267 0b00>. </p>
  
  <p>The output represents the hardware address of the peripheral.</p>
  
  <p>The hardware guys are telling me this is in little-endian, and I know it is a 48-bit string. It is coming from the peripheral, which has its firmware written in C.</p>
  
  <p>I have been trying for a few days to convert this into a string (with the correct endianness) so that I can store the hardware address on our back-end, but am unable to come up with an elegant solution. </p>
  
  <p>One solution I did come up with was reading the :description property of the NSData object, and then manually (in javascript) 'decoding' it. I just do not feel like this solution is proper enough for a production environment, and would like to use native utilities instead.</p>
  
  <p>I have tried using :</p>
  
  <pre><code>NSString.alloc().initWithDataEncoding(mac, NSUTF8StringEncoding);
  </code></pre>
  
  <p>..with every encoding type from <a href="https://developer.apple.com/documentation/foundation/nsstringencoding?language=objc" rel="nofollow noreferrer">THIS</a> page of the documentation. I am either getting nil in return, or incorrect characters.</p>
  
  <p>Like I previously stated, this is being written in NativeScript; however, I have a decent understanding of objective C, so I should be able to convert any examples provided in that language.</p>
  
  <p>Any input would be greatly appreciated. Thanks in advance!</p>