Http request in iOS app

I want to send an HTTP request every time myapp runs. How to do it? I'm trying to:

class MainViewController: UITableViewController {
func my_request(){

        let url = NSURL(string: "http://www.stackoverflow.com")
        let request = NSURLRequest(URL: url)
        let connection = NSURLConnection(request: request, delegate:nil, startImmediately: true)
        println(connection)

        }

        let lol = my_request()
}

      

But I have an error: Missing argument for parameter # 1 when called

How to fix it?

Thank!

+3


source to share


1 answer


my_request () returns nothing, if you just want to call the function use only

my_request()

      



I would suggest putting this in the ViewDidLoad function (on your Main ViewController of your application)

+2


source







All Articles