Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mzaks/FlatBuffersSwift
This project brings FlatBuffers (an efficient cross platform serialization library) to Swift.
https://github.com/mzaks/FlatBuffersSwift
Last synced: 3 months ago
JSON representation
This project brings FlatBuffers (an efficient cross platform serialization library) to Swift.
- Host: GitHub
- URL: https://github.com/mzaks/FlatBuffersSwift
- Owner: mzaks
- License: mit
- Created: 2015-12-29T14:03:33.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-06T17:50:12.000Z (over 5 years ago)
- Last Synced: 2024-04-22T04:15:54.959Z (7 months ago)
- Language: Swift
- Homepage:
- Size: 40.9 MB
- Stars: 570
- Watchers: 19
- Forks: 42
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - FlatBuffersSwift - This project brings FlatBuffers (an efficient cross platform serialization library) to Swift. (Parsing / JSON)
- awesome-ios-star - FlatBuffersSwift - This project brings FlatBuffers (an efficient cross platform serialization library) to Swift. (Parsing / JSON)
README
# FlatBuffersSwift
[![Join the chat at https://gitter.im/mzaks/FlatBuffersSwift](https://badges.gitter.im/mzaks/FlatBuffersSwift.svg)](https://gitter.im/mzaks/FlatBuffersSwift?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/mzaks/FlatBuffersSwift.svg?branch=master)](https://travis-ci.org/mzaks/FlatBuffersSwift)
# Motivation
This project brings [FlatBuffers](https://google.github.io/flatbuffers/) (an efficient cross platform serialization library) to Swift.# One minute introduction
There are three simple steps for you to use FlatBuffersSwift
## 1. Write a schema file
```flatbuffers
table List {
people : [Person];
}table Person {
firstName : string;
lastName : string;
}root_type List;
```## 2. Generate Swift code
`fbsCG` console application can be found here: https://github.com/mzaks/FlatBuffersSwiftCodeGen
To generate, please execute it as following:
`fbsCG contacts.fbs contacts.swift`## 3. Use the generated API
Create objects and encode them
```swift
let p1 = Person(firstName: "Maxim", lastName: "Zaks")
let p2 = Person(firstName: "Alex", lastName: "Zaks")
let list = List(people: [p1, p2])
let data = try?list.makeData()
```
Decode data very efficiently
```swift
let newList = List.from(data: data)
let name = newList?.people[0].firstName
```# Please check out [Wiki](https://github.com/mzaks/FlatBuffersSwift/wiki) for more information.