I am using the following code to host an image on my server.
@IBAction func postButtonPressed(sender: UIButton) {
let task = NSURLSession.sharedSession().dataTaskWithRequest(createRequest("http://xx.xx.xxx.xxx/xxxx/"), completionHandler: {
data, response, error in
println(NSString(data: data, encoding: NSUTF8StringEncoding))
})
task.resume()
}
where createRequest()creates the necessary NSURLRequest object.
This works great when I use the simulator . The problem is that I get the following error when launching the application on the iPhone.
Error Domain=NSURLErrorDomain Code=-1001 "The operation couldn’t be completed. (NSURLErrorDomain error -1001.)" UserInfo=0x155e71f0 {NSErrorFailingURLKey=http:
I found out that this error is a timeout error. Restarting the application or phone did not help. In addition, I tried to host the image on my server from a web browser, and it worked without problems.
What can cause this timeout error?
The EDIT: . When I track activity on the network, I realized that the application is sending 10 MB of data, although the image I'm sending is 0.1 MB.