gpt4 book ai didi

ios - 找不到接受提供的参数的 '!=' 的重载?

转载 作者:行者123 更新时间:2023-11-28 05:34:49 24 4
gpt4 key购买 nike

刚开始使用 swift 尝试编写一些代码来检测是否存在互联网连接。我得到 Could not find an overload for '!=' that accepts the provided arguments on the last line.我做错了什么?

class func hasConnectivity() -> Bool {
let reachability: Reachability = Reachability.reachabilityForInternetConnection()
let networkStatus: NetworkStatus = reachability.currentReachabilityStatus()
return networkStatus != NotReachable
}

最佳答案

返回您要查找的结果的一种方法是打开 networkStatus:

switch networkStatus {
case .NotReachable:
return false
default:
return true
}

关于ios - 找不到接受提供的参数的 '!=' 的重载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24346612/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com