I am trying to access a website. I am using a dataTaskWithURL request.
Here is my code:
let task = NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) in
    print("2")
    if let urlContent = data {
        print("3")
        let stringContent = NSString(data: urlContent, encoding: NSUTF8StringEncoding)!
        let arr = stringContent.componentsSeparatedByString("<b>The computer's solutions will appear below</b><br>")
        let second = arr[1]
        let newArr = second.componentsSeparatedByString("</tr></table></center><p align=\"center\">")
        let results = newArr[0]
        self.resultsLabel.text = results
        self.stopActivity()
    } else {
        print(error)
        self.stopActivity()
    }
})
task.resume()
I have also tried running this code on the main block:
dispatch_async(dispatch_get_main_queue(), {() -> Void in
    // Code
})
However, neither of these has been successful. I repeatedly get the following error
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x7ff0a3f4c6e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=THE URL I AM TRYING TO ACCESS, NSErrorFailingURLKey=THE URL I AM TRYING TO ACCESS, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.})
I have tried looking at this post and this one as well. However, I have not been successful with them. The website loads fairly quickly. How do I get rid of this error?
 
     
     
    