2

As the title suggests, I'm wondering if anyone out there has any good experience in byte conversion and if there is any good tutorial or information about this.

https://codereview.stackexchange.com/questions/114730/type-to-byte-array-conversion-in-swift

This post explains it very well but if I understand it correctly you can only use this on types like Int, float, Double and so on. I want to learn how to convert any type, like a custom made class to bytes.

Community
  • 1
  • 1
nullforlife
  • 1,354
  • 2
  • 18
  • 30
  • 2
    You may also be interested in [round trip Swift number types to/from Data](http://stackoverflow.com/questions/38023838/round-trip-swift-number-types-to-from-data) which is a bit newer and for Swift 3. – *Arbitrary* types may have "non-trivial" properties like strings, arrays, references, pointers, ... You can implement custom pack/unpack methods, or implement the NSCoding protocol and then use the NSKeyed(Un)Archive methods. – Martin R Nov 07 '16 at 10:49
  • 1
    You can see this [gist](https://gist.github.com/anishparajuli555/85aa8a635d5c8cd02a3e5d3f5c829c03) – LC 웃 Nov 07 '16 at 11:01
  • interesting @MartinR I will have a look into that. Also interesting Anish and I will have a look into that as well. – nullforlife Nov 07 '16 at 13:26

0 Answers0