-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protocol Buffer ("protobuf") #111
Comments
Protocol Buffer简介相对于传统的 XML 和 JSON, Protocol buffers 的优势主要在于:更加小、更加快。对于自定义的数据结构,Protobuf 可以通过生成器生成不同语言的源代码文件,读写操作都非常方便。 在 iOS 中使用 PB
原理Protocol BufferProtocol Buffer 的主要优点在于小巧、快速:
这两个优点主要源于两点:
Protocol Buffer 的缺点:
Objective-C 中的 decode 逻辑
在 Protocol Buffer 的 Objective-C 解码库中,解析 PB 数据的逻辑可以简单理解为: 通过在 GPBMessage 子类中实现的 Descriptor(包括 GPBFileDescriptor、 GPBDescriptor 和 GPBFieldDescriptor),指定 Message 以及各属性的一些信息,然后再循环遍历这个 GPBMessage 子类的各个属性对应的 Descriptor,对属性进行赋值。 Protocol Buffer 源码protobuf 是跨平台的,protobuf 大概分成两部分:
参考
|
The text was updated successfully, but these errors were encountered: