iOS错误代码= -1003“找不到具有指定主机名的服务器." [英] iOS Error Code=-1003 "A server with the specified hostname could not be found."
本文介绍了iOS错误代码= -1003“找不到具有指定主机名的服务器."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从iPhone上的URL加载图像,图像在那里,我可以使用相同的链接在safari中打开它,但不能在应用程序中打开它:
I am trying to load image from URL on the iphone, image is there and I can open it in safari with same link, but not in the app:
Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname
could not be found." UserInfo={NSUnderlyingError=0x17024f810
{Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)"
UserInfo={_kCFStreamErrorCodeKey=50331647, _kCFStreamErrorDomainKey=6147928288}},
NSErrorFailingURLStringKey=https://........, NSErrorFailingURLKey=https://.........
请求代码:
func downloadImage(userEmail: String, onCompletion: @escaping (UIImage) -> Void) {
print("Download Started")
let route = "\(baseURL as String)\(userEmail as String)\(baseURLparameters as String)"
let url = URL(string: route)
getDataFromUrl(url: url!) { (data, response, error) in
guard let data = data, error == nil else {
print("===failed:", error ?? "dunno")
print("===url:", url?.absoluteString ?? "dunno")
return
}
print(response?.suggestedFilename ?? url!.lastPathComponent )
print("Download Finished")
DispatchQueue.main.async() { () -> Void in
onCompletion(UIImage(data: data)!)
}
}
}
推荐答案
就我而言,当我将签名团队帐户连接到Xcode时,它会自动打开功能"中的应用程序沙箱" .当我关闭它时,我可以进行服务器请求而没有任何问题.
In my case, when I connect the signing team account to Xcode it was automatically switch on the App Sandbox in Capabilities. When I turn off it I could do server request without any problems.
这篇关于iOS错误代码= -1003“找不到具有指定主机名的服务器."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文