0
votes

I have converted a UIImage in to NSData and now i want to convert that NSData in to NSString so that i can send it to a server. Here is the code

UIImage *img=mainImage.image;
NSData *imgdata=UIImagePNGRepresentation(img);
NSString *imgstr=[imgdata base64Encoding];

but i think iOS6 is not supporting this base64Encoding. Please help me if there is any alternate for base64Encoding for iOS6 or any other way to convert this NSData in to NSString.

1
Did you google for "NSData base64"?Martin R

1 Answers

0
votes

I got solution for the problem. There is nothing like iOS 6 is not supporting Base64Encoding. I have successfully encoded a .png file and then sent to server. After that i retrieve that encoded data on other view in my app. And the Base64Encoding is working quite fine. Earlier the problem was on the server side as when we were saving the Data on server (programing language php) through web service it was replacing "+"symbol with " /" in encoded data. If anybody face such problem please carefully compare the encoded data in the console at two places 1>from where you are sending data after encoding. 2>where you are retrieving the encoded data. After that fix this problem on server side.