Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm new in objecive-C and i would like to decode a NSString encoded in Base64.

Have you any idea to help me?

NSString encoded:

eyJjbGUiOiJwOW5oOTk3eDRxdhpnZzciLCJ1cmwiOiJtbGtqcW1sa3FzbWxmbXFsanFkln0

NSString i try to find:

{"cle":"p9nh997x4qvgg7","url":"mlkjqmlkqsmlfmqljqd}

share|improve this question
3  
Go to google, then ask it for Decode Base64 Objective-C. This should always be your first step. – Almo Feb 1 at 14:54
1  
Now I ask OP and myself too: I'm wondering whether it would have been really so much friggin' difficult to google "Base-64 Objective-C"? – H2CO3 Feb 1 at 14:56
And btw. it is #3 it the [objective-c] faq. – Martin R Feb 1 at 15:12
1  
LOL @Almo went to google, typed "Decode Base64 Objective-C" and this page was the first result! – PassKit Apr 16 at 5:46
Hahaha!!! Google is kind of funny that way! – Almo Apr 16 at 9:19

closed as not constructive by H2CO3, MrSmith42, Mario, Gajotres, Nicolas Bachschmidt Feb 1 at 22:50

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

1 Answer

get a base64 library: https://github.com/l4u/NSData-Base64

Create NSData from the string:

NSData *data = [NSData dataFromBase64String:string];

convert that data to a string

NSString *convertedString = [[NSString alloc] initWithData:data encoding:NSUTF8Encoding];
share|improve this answer
Thank you for your help! – user2032850 Feb 11 at 8:27
Just one rectification : it's "NSUTF8StringEncoding" and not "NSUTF8Encoding". – user2032850 Feb 11 at 8:45
ah right, sorry. i rely on auto-complete too much i guess – wattson12 Feb 11 at 10:43

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