8

How is it possible to get a base64 string from an NSData instance?

3

3 Answers 3

22

please try to search before posting questions I already post a answer for this here - Verifying a Receipt with the App Store - try this function there.

3
  • @Saurabh Please can you tell how to reverse base64 back to data.
    – S.J
    Jun 11, 2013 at 6:19
  • @Saurabh I used this method to convert image data to NSString to send image in mail with HTML code. I can see image in iPhone's mail application but its not working with Gmail only. it's also working with yahoo mail. Can you help me on this? Sep 12, 2013 at 13:33
  • Why does the character table have 65 characters? Oct 21, 2013 at 2:28
1

(if you targeting on IOS 7 ...) There is an easy way using provided API: https://stackoverflow.com/a/19088341/2481444

I also tested the accepted code. They both generate the same result.

It also has decoding function. @S.J

1
NSString* base64String = [nsdata base64Encoding];
1
  • 2
    Please add an explaination why you think that this solves the problem. Otherwise, it lacks context and is likely to be removed due to “low quality”.
    – lxg
    Sep 19, 2014 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.