1

I'm looking at some code somebody else has written which has no documentation, why is this code making a comparison with 65535?

class func canMakePhoneCall() -> Bool
{
    guard let URL = URL(string: "tel://") else {
        return false
    }

    let canOpenURL = UIApplication.shared.canOpenURL(URL)
    if canOpenURL == false
    {
        return false
    }

    let mobileNetworkCode = CTTelephonyNetworkInfo().subscriberCellularProvider?.mobileNetworkCode

    let isInvalidNetworkCode = mobileNetworkCode == nil
        || mobileNetworkCode?.characters.count == 0
        || mobileNetworkCode == "65535"

    return isInvalidNetworkCode == false
}
Gruntcakes
  • 37,738
  • 44
  • 184
  • 378
  • Well it's the maximum size of an unsigned smallint (2 byte) value, does that help? Maybe checking to see if the code is invalid? – Jacob H Jun 07 '18 at 19:37

1 Answers1

0

According to an answer here, this could be an indication of removed SIM card, or in general inability to make a call at the moment.

kovpas
  • 9,553
  • 6
  • 40
  • 44