Issue
You are sending NSData
to server not NSString
, and that's why you are getting this NSData
on that format read by you as NSString
.
Solution
First you need to send it correctly as NSString
to server by doing this:
NSData *imageData= UIImagePNGRepresentation(yourImage);
NSString *encodedString = [imageData base64EncodedStringWithOptions:0];
After you send it to NSString, now you get it back an manipulate it like this. I am using NSData Base64 library to perform this task.
You just manually copy these files to your project. Import the classes to your project and these lines to your code:
#import "NSData+Base64.h"
//This function converts your base64string (NSString Class) to NSData
NSData *data = [[NSData alloc] initWithData:[NSData dataFromBase64String:base64String]];
//Here is where you convert it to UIImage
UIImage *image = [UIImage imageWithData:data];
P.S You can also follow your answer, which to me seems correct, but I just wanted to let you know where were you doing wrong.