如何使用目标C脱code BASE64 EN codeD PNG [英] how to decode BASE64 encoded PNG using Objective C

查看:199
本文介绍了如何使用目标C脱code BASE64 EN codeD PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有些NSData的是BASE64 EN codeD,我想取消code,我所看到的,看起来像这样的堆栈在流动的例子

I have some NSData which is BASE64 encoded and I would like to decode it, I have seen an example on stack over flow that looks like this

NSData* myPNGData = [xmlString dataUsingEncoding:NSUTF8StringEncoding];

[Base64 initialize];
NSData *data = [Base64 decode:img];
cell.image.image = [UIImage imageWithData:myPNGData];

不过这给了我错误的负荷,我想知道怎样才能得到这个工作要做。有一些类型的文件,我需要导入到我的项目还是我必须包括一个框架?

However this gives me a load of errors, I would like to know what to do in order to get this to work. Is there some type of file I need to import into my project or do I have to include a framework?

这是错误的,我得到

Use of undeclared identifier 'Base64'
Use of undeclared identifier 'Base64'
Use of undeclared identifier 'cell'

我已经到处找,不能弄清楚什么是应该做的正确的事情。

I have looked everywhere and cannot figure out what is the proper thing to do.

任何帮助将大大AP preciated。

any help would be greatly appreciated.

推荐答案

NSData的Base64编码库文件会帮助你。

#import "NSData+Base64.h"

//Creating the data from your base64String
NSData *data = [[NSData alloc] initWithData:[NSData
dataFromBase64String:strData]];

//Now data is decoded. You can convert them to UIImage
UIImage *image = [UIImage imageWithData:data];

希望它能帮助

这篇关于如何使用目标C脱code BASE64 EN codeD PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆