So lets say I have a class foo with 10 properties all of which are of type String and I want to create a byte array of length 10 like this:
let data = NSData(bytes: [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,] as [UInt8], length:10)
Each instance of 0x00 would be a property of class foo. How would I go about creating that?
class foo {
var mailbox = "0x00"
var cmd = "0x00"
var data0 = "0x00"
var data1 = "0x00"
var data2 = "0x00"
var data3 = "0x00"
var data4 = "0x00"
var data5 = "0x00"
var data6 = "0x00"
var data7 = "0x00"
}
Then the byte array would contain:
let data = NSData(bytes:[foo.mailbox, foo.cmd, foo.data0, foo.data1, foo.data2, foo.data3, foo.data4, foo.data5, foo.data6, foo.data7] as [UInt8], length:10)