I'm creating an app that uploads an image to a server. It must send the byte array on a XML. How do I get the byte array into a NSString?
Thanks!
I'm creating an app that uploads an image to a server. It must send the byte array on a XML. How do I get the byte array into a NSString?
Thanks!
Here is a simple function for iOS to convert from UIImage to unsigned char* byte array -->
You can convert the UIImage to a NSData object and then extract the byte array from there. Here is some sample code:
If you are using a PNG Image you can use the UIImagePNGRepresentation function as shown above or if you are using a JPEG Image, you can use the UIImageJPEGRepresentation function. Documentation is available on the UIImage Class Reference
using
NSData *data = UIImagePNGRepresentation(image);
you can convert image into data , now convert dat to bytes by usinggetBytes:length:
orgetBytes:range: