I tried to add function from objective c to swift just like here https://stackoverflow.com/a/29440193/7395969 and I converted call method to Swift as shown below. But I get error : Cannot convert value of type 'in_addr_t' (aka 'UInt32') to expected argument type 'UnsafeMutablePointer!' on this line : let r: Int
func getGatewayIP() -> String {
var ipString: String? = nil
let gatewayaddr: in_addr
let r: Int = getdefaultgateway((gatewayaddr.s_addr))
if r >= 0 {
ipString = "\(inet_ntoa(gatewayaddr))"
print("default gateway : \(ipString)")
}
else {
print("getdefaultgateway() failed")
}
return ipString!
}