0

I need to send a files to a XML web service. The web service only accepts the file in a base64 format and rebuilds it in the back end. I need to know how do i convert a file to base64 in Objective C.

Radu
  • 3,434
  • 4
  • 27
  • 38
  • http://stackoverflow.com/questions/392464/any-base64-library-on-iphone-sdk – Marko Hlebar Apr 18 '11 at 09:20
  • a quick search would reveal many answers.... you should at least look for an answer before posting a new question... – Swapnil Luktuke Apr 18 '11 at 09:37
  • I already wrote code for NSString to base64 for AES Encryption. What I need is to know is how can I convert any type of file into base64 or at least into a NSString sow i can send it to a web service – Radu Apr 18 '11 at 11:07

2 Answers2

0
UIGraphicsBeginImageContext(view.bounds.size);       
[view.layer renderInContext:UIGraphicsGetCurrentContext()];  
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();  
NSData *imagedata = UIImagePNGRepresentation(viewimage);  
NSString *encodedString = [imageData base64Encoding];

where view is the view where lines are drawn.

dks1725
  • 1,631
  • 1
  • 20
  • 29