Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 182 Vote(s) - 3.45 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check for internet connection with Swift

#1
When I try to check for an internet connection on my iPhone I get a bunch of errors. Can anyone help me to fix this?

The code:

import Foundation
import SystemConfiguration

public class Reachability {

class func isConnectedToNetwork() -> Bool {

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 = 0

if SCNetworkReachabilityGetFlags(defaultRouteReachability, &flags) == 0 {
return false
}

let isReachable = (flags & UInt32(kSCNetworkFlagsReachable)) != 0
let needsConnection = (flags & UInt32(kSCNetworkFlagsConnectionRequired)) != 0

return (isReachable && !needsConnection) ? true : false
}

}


The errors with the code:

![Errors][1]


[1]:


If it is unreadable, error 1 says:

>'Int' is not convertible to 'SCNetworkReachabilityFlags'

Error 2 & 3:

>Could not find an overload for 'init' that accepts the supplied arguments
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through