0

in my app i have to upload byte array(Audio ) to server .

BUt now We are getting Nsdata .How to convert this Nsdata to Byte array to post the Audio file to server

Can any one help me?

naga
  • 35
  • 1
  • 7

1 Answers1

1

your can use bytes method of NSData;

NSUInteger len = [yourData length];
Byte *byteData = (Byte*)malloc(len);
memcpy(byteData, [yourData bytes], len);

If your byte is null terminated you can use

NSString *content = [NSString stringWithUTF8String:[yourData bytes]];

and if not

NSString *content = [[NSString alloc]  initWithBytes:[yourData bytes]
          length:[yourData length] encoding: NSUTF8StringEncoding];
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167