Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mingchen/protobuf-ios

[Deprecated] An Objective-C implementation of Google proto buffer for iOS
https://github.com/mingchen/protobuf-ios

Last synced: 18 days ago
JSON representation

[Deprecated] An Objective-C implementation of Google proto buffer for iOS

Awesome Lists containing this project

README

        

# protobuf-ios

## Introduction

[![travis-ci build status](https://travis-ci.org/mingchen/protobuf-ios.svg?branch=master)](https://travis-ci.org/mingchen/protobuf-ios)

An **Objective-C** implementation of Google **proto buffer** for **iOS**.
The orignal code comes from [Booyah Inc](https://github.com/booyah/protobuf-objc). This implemenation add features to support write to / parse from delimited stream. This git repo also support [cocoapods](http://cocoapods.org).

## Supported Platform

* iOS 4.0 and above
* Xcode 4 and above

## Features

- Support write to / parse from delimited stream (protobuf 2.3 feature).

## Examples

### Simple Usage

You write a `foo.proto` file like this:

message Person {
required int32 id = 1;
required string name = 2;
optional string email = 3;
}

Then you compile it with `protoc` to produce code in Objective-C (see below).

Serialize to protobuf format:

Person* person = [[[[[Person builder] setId:123]
setName:@"Bob"]
setEmail:@"[email protected]"] build];
NSData* data = [person data];

Unserialize from protobuf format data:

NSData* raw_data = ...;
Person* person = [Person parseFromData:raw_data];

### Delimited encode

Sometime is very useful to write multiple protobuf objects into a single file.
This need use delimited format. Here is an example:

// serialize
NSOutputStream *ouputStream = [NSOutputStream outputStreamToFileAtPath:@"filename.dat" append:YES];
[ouputStream open];
for (int i=0; i