class 实现一个判断ipv4的逻辑: BaseViewController {
    
    var testArray: [String] = ["192.168.1.1", "255.255.255.255", "0.0.0.0", "256.1.1.1", "123.045.067.089", "192.168.1"]

    override func viewDidLoad() {
    
        for ip in testArray {
            if isString(ip) {
                checkIPv4(ip)
            } else {
                print("prama is error")
            }
        }
        
        // check ipv4 is error
        func checkIPv4(_ ip: String) {
            let ipArray = ip.split(separator: ".")
            if ipArray.count != 4 {
                print("this is not a ipv4 address,ip count is error")
                return
            }
            for i in ipArray {
                if  i.count > 1 && i.first == "0" {
                    print("this is not a ipv4 address, the first character is string '0'")
                    return
                }
                guard let number = Int(i) else { return }
                if number < 0 || number > 255 {
                    print("this is not a ipv4 address")
                    return
                }
                
            }
            print("this is a ipv4 address")
        }
        
        func isString(_ value: Any) -> Bool {
            return value is String
        }
    }
}