& quot; NSURLErrorDomain& quot;-代码:18446744073709550594 Xcode 7上的Ajax调用 [英] "NSURLErrorDomain" - code: 18446744073709550594 Ajax call on Xcode 7

查看:68
本文介绍了& quot; NSURLErrorDomain& quot;-代码:18446744073709550594 Xcode 7上的Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按如下所示从Xcode 7进行异步调用,但最终看到此错误"NSURLErrorDomain"-代码:18446744073709550594当我在Xcode 6中使用此代码时,它很好.其他人看到此错误了吗?

I am trying to make an asynchronous call from Xcode 7 as follows and I end up seeing this error "NSURLErrorDomain" - code: 18446744073709550594 This code was fine when I used it in Xcode 6. Has anybody else seen this error?

var task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: {
            (var data, response, error) -> Void in

            if(response != nil) {
                if (isJSONP){
                    if let prefixData = "(".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) {
                        var prefixRange = data!.rangeOfData(prefixData,options:NSDataSearchOptions(), range: NSMakeRange(0, data!.length))
                        if let suffixData = ")".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) {
                            var suffixRange = data!.rangeOfData(suffixData, options: NSDataSearchOptions(), range: NSMakeRange(0, data!.length))
                            var jsonRange = NSMakeRange(prefixRange.location + 1, data!.length - prefixRange.location - 3 - suffixRange.length)
                            data = data!.subdataWithRange(jsonRange)
                            json_str = NSString(data: data!, encoding: NSUTF8StringEncoding)!
                            //     println(json_str)
                        }

                    }

                }
                do {
                    let jsonData:AnyObject? = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers)
                    callback(jsonData: jsonData)
                } catch {
                    print("JSONData not serialized properly or no data exists correctly")
                }

            }// else results not found properly/ trouble accessing server. please try again later
            else {
                var alert = UIAlertController(title: "Alert", message: "Trouble accessing server. Please try again later", preferredStyle: UIAlertControllerStyle.Alert)
                alert.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.Default, handler: nil))
                self.presentViewController(alert, animated: true, completion: nil)
            }


        })

        task.resume()

这是我使用的代码.我既没有看到数据,也没有回应.我尝试使用其他应用程序访问相同的URL,并且响应正确.我在任何地方都看不到任何文档,因此请在此处发布.任何帮助将不胜感激.

This is the code I have used. I am neither seeing data nor a response. I tried to hit the same url using other applications and it is responding back properly. I do not see any documentation on this anywhere so posting it here. Any help would be appreciated.

谢谢

尼基尔

推荐答案

似乎是一个错误,我通过将所有请求都保留在https下来解决此问题,据我所知,尽管命中ios9.0和9.0.1需要允许url异常,如Apple文档在Info.plist中建议的

Seems to be a bug, I work around it by keeping under https all requests, hits ios9.0 and 9.0.1 as far as I can tell although you need to allow the url exception as apple documentation suggest in the Info.plist

参考 https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

这篇关于& quot; NSURLErrorDomain& quot;-代码:18446744073709550594 Xcode 7上的Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆