In my SWIFT code I need to switch based on the ended-ness of the local host, so I call CFByteOrderGetCurrent():
import Framework
let localMachineByteOrder = CFByteOrderGetCurrent()
So far, so good - but I'm struggling to find a readible way to interpret the results. I was expecting to be able to say this:
if localMachineByteOrder == .CFByteOrderLittleEndian { ... }
However Xcode doesn't like it: "type of expression is ambiguous without more context". The best I've been able to achieve so far, with help from a developer on another forum, is this:
if localMachineByteOrder == CFByteOrder(1) // 1 is the index of 'CFByteOrderLittleEndian' in the CFByteOrder enum
But that seems like rather unreadable code, and it would fail if the ordering of the constants in CFByteOrder changed.
Surely there must be a way to do this with symbolic constants!! Maybe I am reading the documentation wrongly but I am finding this very opaque... I would be very grateful for some guidance on this 🙂
Thanks in advance, Martin