Tutorial by Examples

// define url let url = NSURL(string: "https://urlToGet.com") //create a task to get data from a url let task = NSURLSession.sharedSession().dataTaskWithURL(url!) { /*inside this block, we have access to NSData *data, NSURLResponse *response, and NSError...
NSURL *url = [NSURL URLWithString:@"http://www.example.com/"]; NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; // Configure the session here. NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration]; [[s...
To create a background session // Swift: let mySessionID = "com.example.bgSession" let bgSessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(mySessionID) let session = NSURLSession(configuration: bgSessionConfig) // add tasks here //...
There are two common ways to encode a POST request body: URL encoding (application/x-www-form-urlencoded) and form data (multipart/form-data). Much of the code is similar, but the way you construct the body data is different. Sending a request using URL encoding Be it you have a server for your s...

Page 1 of 1