diff options
author | mustiikhalil <mustii@mmk.one> | 2020-01-13 23:34:06 +0300 |
---|---|---|
committer | Wouter van Oortmerssen <aardappel@gmail.com> | 2020-01-13 12:34:06 -0800 |
commit | a4b2884e4ed6116335d534af8f58a84678b74a17 (patch) | |
tree | 73a9fc0f7e747c3333e50f4523db42c49ccde881 /docs/source | |
parent | 04d80f255d1c2fa7a466e8465a119c0eaef26d59 (diff) | |
download | flatbuffers-a4b2884e4ed6116335d534af8f58a84678b74a17.tar.gz flatbuffers-a4b2884e4ed6116335d534af8f58a84678b74a17.tar.bz2 flatbuffers-a4b2884e4ed6116335d534af8f58a84678b74a17.zip |
Added create function for swift (#5707)
Fixed the create functions and updated the test cases in swift
Removes unneeded code
Updated documentation
Diffstat (limited to 'docs/source')
-rw-r--r-- | docs/source/Tutorial.md | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/docs/source/Tutorial.md b/docs/source/Tutorial.md index 00408b52..f871c4c0 100644 --- a/docs/source/Tutorial.md +++ b/docs/source/Tutorial.md @@ -1699,16 +1699,15 @@ can serialize the monster itself: </div> <div class="language-swift"> ~~~{.swift} - let start = Monster.startMonster(builder) - Monster.add(pos: pos, builder) - Monster.add(hp: 300, builder) - Monster.add(name: name, builder) - Monster.add(inventory: inventoryOffset, builder) - Monster.add(color: .red, builder) - Monster.add(weapons: weaponsOffset, builder) - Monster.add(equippedType: .weapon, builder) - Monster.add(equipped: axe, builder) - var orc = Monster.endMonster(builder, start: start) + let orc = Monster.createMonster(builder, + offsetOfPos: pos, + hp: 300, + offsetOfName: name, + vectorOfInventory: inventoryOffset, + color: .red, + vectorOfWeapons: weaponsOffset, + equippedType: .weapon, + offsetOfEquipped: axe) ~~~ </div> @@ -1776,6 +1775,21 @@ a bit more flexibility. ~~~ </div> +<div class="language-swift"> +~~~{.swift} + let start = Monster.startMonster(builder) + Monster.add(pos: pos, builder) + Monster.add(hp: 300, builder) + Monster.add(name: name, builder) + Monster.addVectorOf(inventory: inventoryOffset, builder) + Monster.add(color: .red, builder) + Monster.addVectorOf(weapons: weaponsOffset, builder) + Monster.add(equippedType: .weapon, builder) + Monster.add(equipped: axe, builder) + var orc = Monster.endMonster(builder, start: start) +~~~ +</div> + Before finishing the serialization, let's take a quick look at FlatBuffer `union Equipped`. There are two parts to each FlatBuffer `union`. The first, is a hidden field `_type`, that is generated to hold the type of `table` referred |