Internet connection IOS Xcode 7

1

Is it possible to disable the internet connection in the IOS simulator of xcode 7?

    
asked by 13.06.2016 в 11:03
source

3 answers

1

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 )

    
answered by 13.06.2016 / 11:20
source
1

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
    }
    
answered by 15.06.2016 в 08:32
0

Although it is very banal, disconnect the Wifi when you need it and ready. Otherwise, you can use the tool commented by the partner.

    
answered by 13.06.2016 в 16:07