Files
flatbuffers-bigfoot/swift/Sources/FlatBuffers/Documentation.docc/Tutorials/reading_bytebuffer.tutorial
mustiikhalil f63c130c28 Improves documentation, and adding DocC (#6784)
Finished documenting flatbuffersbuilder

Replaces swift 5.5 with 5.2 packages

Starts building the tutorial for xcode 13

Finishes building the tutorial for xcode 13

Removes docc files from old swift versions

Updates swift style guide
2021-09-27 20:59:19 +02: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")
}
}
}
}