引用于GitHub:https://github.com/xiaoxiaocainiao/HostToIP/blob/master/HostToIP/ViewController.swift
这里又根据自己需要做了少许改动,在此感谢下作者的无私提供。
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
getIPAddress("www.baidu.com")
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// 域名解析
func getIPAddress(domainName: String) -> String {
var result = ""