damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

swift_code_12.swift (533B)


      1 import FlatBuffers
      2 import Foundation
      3 
      4 func run() {
      5   // create a ByteBuffer(:) from an [UInt8] or Data()
      6   let buf = [] // Get your data
      7   var byteBuffer = ByteBuffer(bytes: buf)
      8   // Get an accessor to the root object inside the buffer.
      9   let monster: Monster = try! getCheckedRoot(byteBuffer: &byteBuffer)
     10   // let monster: Monster = getRoot(byteBuffer: &byteBuffer)
     11 
     12   let hp = monster.hp
     13   let mana = monster.mana
     14   let name = monster.name // returns an optional string
     15 
     16   let pos = monster.pos
     17   let x = pos.x
     18   let y = pos.y
     19 }