This project brings FlatBuffers (an efficient cross platform serialization library) to Swift.
There are three simple steps for you to use FlatBuffersSwift
table List {
people : [Person];
}
table Person {
firstName : string;
lastName : string;
}
root_type List;
fbsCG
console application can be found here: https://github.com/mzaks/FlatBuffersSwiftCodeGen
To generate, please execute it as following:
fbsCG contacts.fbs contacts.swift
Create objects and encode them
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
let newList = List.from(data: data)
let name = newList?.people[0].firstName