1
0
mirror of git://jb55.com/damus synced 2024-09-21 04:27:31 +00:00
damus/flatbuffers/Documentation.docc/Tutorials/reading_bytebuffer.tutorial
2023-08-26 20:46:42 -07:00

28 lines
1.1 KiB
Plaintext

@Tutorial(time: 2) {
@Intro(title: "Reading ByteBuffers") {
After getting our ByteBuffer created, we can now read it.
}
@Section(title: "Reading your first buffer") {
@ContentAndMedia {}
@Steps {
@Step {
After fetching the data from disk or network you need to access that data, and that can be done.
By simply calling `getCheckedRoot`, which checks if the data is valid before enabling you to read from a corrupt buffer.
however, if you are sure that the data is 100% correct you can simply call `getRoot`
@Code(name: "ViewController.swift", file: "swift_code_11.swift")
}
@Step {
Now since we have a Monster object, all the fields can be accessed by simply fetching the data. Note, Deprecated fields will not
show up
@Code(name: "ViewController.swift", file: "swift_code_12.swift")
}
@Step {
And you can access union types as easy as this
@Code(name: "ViewController.swift", file: "swift_code_13.swift")
}
}
}
}