Determine if an email can be sent

Since iPhones have access to Cellphone networks as well as WiFi networks, but iTouch only has access to Wifi

if there a declare or other method to determine if the “device” is in a situation where an email can even be attempted?

ie. does iPhone have either Cell or WiFi service, or an iTouch has WiFi service

Jason King has created a Reachability class that tells you exactly the kind of network available.

See https://forum.xojo.com/18059-online-or-not

I suppose you can look at what it uses to apply that to Swift.

I hope you all realize that code won’t work in certain countries (such as China), or anywhere else where GOOGLE.COM is blocked, which is alot of places outside US/Canada/SouthAmerica and Europe

So if flags=2 then the network CAN be reached, but there is no connection?
it would have to be isWWAN and/or isLocalAddress to be either a cell connection or wifi connection?

I found swift code, but it returns 2 but doesn’t “care” as long as the value is “2”

and I don’t know if this helps… but instead of SCNetworkReachabilityCreateWithName with requires “GOOGLE.COM
this uses

 var zeroAddress = sockaddr_in()
    zeroAddress.sin_len = UInt8(sizeofValue(zeroAddress))
    zeroAddress.sin_family = sa_family_t(AF_INET)
    let defaultRouteReachability = withUnsafePointer(&zeroAddress) {
        SCNetworkReachabilityCreateWithAddress(nil, UnsafePointer($0))
    }
    var flags = SCNetworkReachabilityFlags()

my iTouch returns 0 if wifi is off , and 2 if WiFi is on… shouldn’t it return 65536 if Wifi is on?