title: Convert NSData to byte array
body: <p>I want to convert the NSData into byte array and given below is the code that i have used</p>
  
  <pre>
      NSData *imageData = UIImagePNGRepresentation(recipeImage.image);
      NSUInteger len = [imageData length];
      Byte *byteData = (Byte*)malloc(len);
      memcpy(byteData, [imageData bytes], len);
      NSLog(@"%8s",byteData);
  </pre>
  
  <p>But its giving me an error when i post the byteData to the webservice which is given below</p>
  
  <p>"Server was unable to process request. ---&gt; Parameter is not valid."</p>
  
  <p>and when i print the byteData this is what i get in the console</p>
  
  <pre>
  âPNG
  </pre>
  
  <p>I tried searching the docs for NSData and found the getBytes method but that too was not of any use i was still getting the same error.</p>
  
  <p>Could you please let me know from the code above as in where i am wrong or what mistake i am making in converting the data into byte array</p>
  
  <p>Edit: I have tried using the </p>
  
  <pre>
  [imageData getBytes:&byteData length:length];
  </pre>
  
  <p>Its giving me a bad access error</p>