-1

I'm trying to create a wifi tress test by opening multiple URLs in succession in Xcode/Swift for iPad. It seems to open only the first successfully. The "sleep(x)" call makes no difference. Code snippet:

func counter()
{
    seconds -= 1
    label.text = String(seconds) + " Seconds"

    if (seconds == 0)
    {

        let url1 = URL(string: "http://www.wix.com")!
        let url2 = URL(string: "http://www.activistpost.com")!
        let url3 = URL(string: "http://www.time.com")!
        let url4 = URL(string: "http://www.steemit.com")!
        let url5 = URL(string: "http://www.youtube.com")!
        let url6 = URL(string: "http://www.cptts.net/61m.jpg")!

        if #available(iOS 10.0, *) {
            UIApplication.shared.open (url1)
            sleep (5)
            UIApplication.shared.open (url2)
            sleep (5)
            UIApplication.shared.open (url3)
            sleep (5)
            UIApplication.shared.open (url4)
            sleep (5)
            UIApplication.shared.open (url5)
            sleep (5)
            UIApplication.shared.open (url6)

        } else {
           // Fallback on earlier versions
        }

Xcode 10.0 Beta 2

wiwinut
  • 75
  • 1
  • 7

2 Answers2

1

I'm trying to create a wifi tress test

Well, that's not how to do it. Also, I wonder whether you really need to do it; the developer tools already allow you to simulate a busy network for testing purposes.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Thank you for your response. As a wifi tester I'd like to develop my own apps for testing that can be customized (also for self-learning for Xcode dev.). What I posted was only a snippet. – wiwinut Jul 24 '18 at 18:31
  • Wifi tester, uuh? Maybe you instead want to load the websites with NSUrlSession? – Carsten Hagemann Jul 24 '18 at 20:10
0

As i quote from Apple documentation, it appears to be it will only execute the first and the app will quit and it will launch the other app if found.

The URL you pass to this method can identify a resource in the app that calls the method, or a resource to be handled by another app. If the resource is to be handled another app, invoking this method might cause the calling app to quit so the other can launch.

So eventually ones your app quits then your other calls won't by executed.

AaoIi
  • 8,288
  • 6
  • 45
  • 87