您的位置:首页 > 移动开发 > IOS开发

Thrift框架学习笔记 IOS/MAC中使用Thrift框架

2016-08-18 16:04 246 查看
一片中文CSDN入门博客

http://blog.csdn.net/yohunl/article/details/41748511

Thrift首页(英文)

http://thrift.apache.org/

OC使用文档(英文)

http://wiki.apache.org/thrift/ThriftUsageObjectiveC

github库

https://github.com/Mantle/Mantle

1.thrift的安装
https://github.com/apache/thrift

官方的安装实在是太麻烦了,我使用brew安装变得特别简单 http://stackoverflow.com/questions/23455499/cant-install-thrift-on-mac-os-10-9-2
先 sudo brew update  
再 sudo brew install thrift
安装完成后,直接在



并且系统还会在 usr/local/bin下面增加一个链接  
(由于我自己将我们自己生成的thrift命令拷贝到了usr/local/bin下,所以会出现一个警告,说我已经有一个链接了,问我是否覆盖 ,覆盖用命令 brew link --overwrite thrift)

使用这个命令,直接覆盖了,生成一个软连接,到thrift



使用的话 可以先用 thrift -help来查看命令

2.最基本的使用 http://blog.csdn.net/blue_jjw/article/details/9147165
建立一个thrift文件
比如
//idl.thrift
struct Message {
     1: string text,
     2: string date
}

service BulletinBoard {
    void add(1: Message msg),
    list<Message> get()

}

然后使用命令 thrift --gen cocoa idl.thrift就可以在当前目录下生成



3.在项目中使用,首先项目中肯定要添加thrift框架啊 (就是从官方的gitHub https://github.com/apache/thrift 下载源码,然后找到
lib/cocoa,将其拷贝到你工程里,就可以了 )

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息