Is it possible to disable the internet connection in the IOS simulator of xcode 7?
Is it possible to disable the internet connection in the IOS simulator of xcode 7?
There is an xcode tool that simulates good and bad connectivity environments. Maybe you can simulate a bad bad connection and / or practically no or no and so have no internet in the simulator. Let's see if it works. ( link )
Another option that could serve you would be to simulate a slow network, this github package could help you. ( link )
I finally "solved" it in the following way:
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()
if !SCNetworkReachabilityGetFlags(defaultRouteReachability!, &flags) {
return false
}
let isReachable = (flags.rawValue & UInt32(kSCNetworkFlagsReachable)) != 0
let needsConnection = (flags.rawValue & UInt32(kSCNetworkFlagsConnectionRequired)) != 0
return (isReachable && !needsConnection)
}
if !isConnectedToNetwork() {//Por defecto da 1, al añadir !, simulo que no hay internet
leo de bbdd
}
else {
leo de xml
}
Although it is very banal, disconnect the Wifi when you need it and ready. Otherwise, you can use the tool commented by the partner.