惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
U
Unit 42
B
Blog RSS Feed
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
腾讯CDC
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Visual Studio Blog
博客园 - 聂微东
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta

博客园 - 1901

试用Github Pages iOS设备内存及分辨率 测试显示GitHub的Gist 颜色转换工具 先随便记一下 iOS中获取程序相关的一些目录路径 mac字典词库增加方法 Google的Logo记现代舞先驱玛莎·葛兰姆117周年诞辰-Flash版 关于flash加载flash时的缩放和位置问题 给力壁纸 for mac 【转载】巧用宏定义来简写C,C++代码 Objective-C中的NSObject对象经常使用到的方法 Objective-C属性介绍 应用程序本地化-国家代码介绍(ISO 3166-1) iPhone开发资料 sourceMate2 我在MACOS下常用的软件 【转载】分享一些FLASH开发时用到的工具~ 关于ActionScript3中的事件类强制转换失败的问题
使用GTMBase64编码解码字符串
1901 · 2012-04-10 · via 博客园 - 1901

使用GTMBase64需要在工程中加入三个文件

示例代码:

#import "GTMBase64.h"

- (void)testExample
{
    NSData *data = [@"HelloWorld" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
    NSString* encoded = [[NSString alloc] initWithData:[GTMBase64 encodeData:data] encoding:NSUTF8StringEncoding]; 
    NSLog(@"encoded:%@", encoded);
    NSString* decoded = [[NSString alloc] initWithData:[GTMBase64 decodeString:encoded] encoding:NSUTF8StringEncoding];
    NSLog(@"decoded:%@", decoded);
    [encoded release];
    [decoded release];
}

输出:

2012-04-10 12:13:10.121 fs_test[7370:b603] encoded:SGVsbG9Xb3JsZA==
2012-04-10 12:13:10.122 fs_test[7370:b603] decoded:HelloWorld

--kaixuan's cnblogs

posted @ 2012-04-10 12:40  1901  阅读(4135)  评论()    收藏  举报