damus

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

reading_bytebuffer.tutorial (1096B)


      1 @Tutorial(time: 2) {
      2   @Intro(title: "Reading ByteBuffers") {
      3     After getting our ByteBuffer created, we can now read it.
      4     }
      5     
      6     @Section(title: "Reading your first buffer") {
      7       @ContentAndMedia {}
      8       @Steps {
      9         @Step {
     10           After fetching the data from disk or network you need to access that data, and that can be done.
     11           By simply calling `getCheckedRoot`, which checks if the data is valid before enabling you to read from a corrupt buffer.
     12           however, if you are sure that the data is 100% correct you can simply call `getRoot`
     13           @Code(name: "ViewController.swift", file: "swift_code_11.swift")
     14         }
     15         @Step {
     16           Now since we have a Monster object, all the fields can be accessed by simply fetching the data. Note, Deprecated fields will not
     17           show up
     18           @Code(name: "ViewController.swift", file: "swift_code_12.swift")
     19         }
     20         @Step {
     21           And you can access union types as easy as this
     22           @Code(name: "ViewController.swift", file: "swift_code_13.swift")
     23         }
     24       }
     25     }
     26   }
     27