ios - Swift - contentsOfURL returns 'nil' with specific site, but it works on browser -
this code works other url's, not one. returns nil "contentsofurl". why?
var url = nsurl(string: "http://www.bsnpr.com/api/standing.asp?serie=1&liga=1&y=2015") var err: nserror? var data = nsdata(contentsofurl: url!, options: nil, error: &err) "err" delivers message:
"optional(error domain=nscocoaerrordomain code=256 "the operation couldn’t completed. (cocoa error 256.)" userinfo=0x7f8f32c2e1e0 {nsurl=http://www.bsnpr.com/api/standing.asp?serie=1&liga=1&y=2015})"
any ideas? in advance.
your server delivers data transfer-encoding set chunked, , nsdata doesn't it.
you can data rest framework alamofire:
alamofire.request(.get, "http://www.bsnpr.com/api/standing.asp?serie=1&liga=1&y=2015") .responsejson { (request, response, json, error) in println(json) // works url, tested }
Comments
Post a Comment