I am making an app that connect between iPhone.
It use enum specify UInt32. but sizeof() is different size.
Why not equal a UInt32?
enum Message:UInt32{
case A = 1
case B = 2
case C = 3
}
sizeof(UInt32) // 4
sizeof(Message) // 1
I am making an app that connect between iPhone.
It use enum specify UInt32. but sizeof() is different size.
Why not equal a UInt32?
enum Message:UInt32{
case A = 1
case B = 2
case C = 3
}
sizeof(UInt32) // 4
sizeof(Message) // 1
They must be optimising the storage, the following works:
sizeofValue(Message.A.toRaw()) // 4
When calling an instance of an enum object with no additional method, it returns the type of enum it is (UInt32, in this case).
In reference to this answer, Types in objective-c on iPhone , an Unsigned Int is 32 4 bytes.