I have received some data in base64string format from JSON pasring in iphone. Now i want that data to store or decode in String. I have user Base64 class. It return me null value. so pls help me!!!
I hope it will helpful to you
NSString *decodeString = @"Raja";
Encode String
NSData *encodeData = [decodeString dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64String = [encodeData base64EncodedStringWithOptions:0];
NSLog(@"Encode String Value: %@", base64String);
Decode String
NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];
NSLog(@"Decode String Value: %@", decodedString);
Try to use like this..First you need to get this base64 library
https://github.com/l4u/NSData-Base64
And then import this file
#import "NSData+Base64.h"
NSData *data = [NSData dataFromBase64String:baseString];
NSString *convertedString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
I hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With