I'm trying to set integer endianness using htonl()
in Swift but the compiler isn't finding the htonl()
method.
I've been using this as my reference: Append NSInteger to NSMutableData
Here's my code:
import Foundation
import CFNetwork
import CoreFoundation
var data = NSMutableData()
var number : UInt32 = 12
var convertedNumber : UInt32 = htonl(number)
data.appendBytes(&convertedNumber, length: 4)
I've just been running this in a playground. The error is:
Use of unresolved identifier 'htonl'