xcode NSURLConnection 错误代码 -1100
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46428633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NSURLConnection Error Code -1100
提问by user1391152
I am trying to load content into UIWebView, and when testing in the simulator all I get is a white screen and the following error in the console:
我正在尝试将内容加载到 UIWebView 中,在模拟器中进行测试时,我得到的只是白屏和控制台中的以下错误:
NSURLConnection finished with error - code -1100
Can anybody help? My current Swift Code is:
有人可以帮忙吗?我目前的 Swift 代码是:
class ViewController: UIViewController {
@IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
webView.allowsInlineMediaPlayback = true;
webView.mediaPlaybackRequiresUserAction = false;
webView.loadRequest(URLRequest(url: URL(fileURLWithPath: Bundle.main.path(forResource: "www/index", ofType: "html")!)))
let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView
statusBar?.backgroundColor = UIColor.clear
}
}
Just to clarify, this code usual works for me, but I can't find anything online relating to error -1100. Many thanks.
澄清一下,这段代码通常对我有用,但我在网上找不到与错误 -1100 相关的任何内容。非常感谢。
回答by Yun CHEN
-1100
means NSURLErrorFileDoesNotExist
. And you are accessing a local file, print the URL's absoluteString
to check the path is good for that file.
-1100
是指NSURLErrorFileDoesNotExist
。并且您正在访问本地文件,打印 URLabsoluteString
以检查路径是否适合该文件。
回答by ssowri1
For mine, The network didn't connected properly. Then I turned on my data connection after that I solved it.
对于我的,网络没有正确连接。然后我打开我的数据连接之后我解决了它。
回答by 9dan
Short description for all NSURLRequest
error codes: URL Loading System Error Codes
所有NSURLRequest
错误代码的简短描述:URL 加载系统错误代码
- NSURLErrorUnknown
- NSURLErrorUnknown
Returned when the URL Loading system encounters an error that it cannot interpret.
当 URL 加载系统遇到无法解释的错误时返回。
- NSURLErrorCancelled
- 已取消 NSURL 错误
Returned when an asynchronous load is canceled.
取消异步加载时返回。
- NSURLErrorBadURL
- NSURLErrorBadURL
Returned when a URL is sufficiently malformed that a URL request cannot be initiated
当 URL 的格式严重到无法发起 URL 请求时返回
- NSURLErrorTimedOut
- NSURLErrorTimedOut
Returned when an asynchronous operation times out.
当异步操作超时时返回。
- NSURLErrorUnsupportedURL
- NSURLErrorUnsupportedURL
Returned when a properly formed URL cannot be handled by the framework.
当框架无法处理格式正确的 URL 时返回。
- NSURLErrorCannotFindHost
- NSURLErrorCannotFindHost
Returned when the host name for a URL cannot be resolved.
当无法解析 URL 的主机名时返回。
- NSURLErrorCannotConnectToHost
- NSURLErrorCannotConnectToHost
Returned when an attempt to connect to a host has failed.
当尝试连接到主机失败时返回。
- NSURLErrorDataLengthExceedsMaximum
- NSURLErrorDataLengthExceedsMaximum
Returned when the length of the resource data exceeds the maximum allowed.
当资源数据的长度超过允许的最大值时返回。
- NSURLErrorNetworkConnectionLost
- NSURLErrorNetworkConnectionLost
Returned when a client or server connection is severed in the middle of an in-progress load.
当客户端或服务器连接在正在进行的加载过程中被切断时返回。
- NSURLErrorDNSLookupFailed
- NSURLErrorDNSLookupFailed
See NSURLErrorCannotFindHost
见 NSURLErrorCannotFindHost
- NSURLErrorHTTPTooManyRedirects
- NSURLErrorHTTPTooManyRedirects
Returned when a redirect loop is detected or when the threshold for number of allowable redirects has been exceeded (currently 16).
当检测到重定向循环或超过允许重定向次数的阈值(当前为 16)时返回。
- NSURLErrorResourceUnavailable
- NSURLErrorResourceUnavailable
Returned when a requested resource cannot be retrieved.
当无法检索到请求的资源时返回。
- NSURLErrorNotConnectedToInternet
- NSURLErrorNotConnectedToInternet
Returned when a network resource was requested, but an internet connection is not established and cannot be established automatically, either through a lack of connectivity, or by the user's choice not to make a network connection automatically.
当请求网络资源但未建立 Internet 连接且无法自动建立 Internet 连接时返回,这可能是由于缺乏连接或用户选择不自动建立网络连接。
- NSURLErrorRedirectToNonExistentLocation
- NSURLErrorRedirectToNonExistentLocation
Returned when a redirect is specified by way of server response code, but the server does not accompany this code with a redirect URL.
当通过服务器响应代码指定重定向时返回,但服务器不将此代码与重定向 URL 一起使用。
- NSURLErrorBadServerResponse
- NSURLErrorBadServerResponse
Returned when the URL Loading system receives bad data from the server.
当 URL Loading 系统从服务器接收到错误数据时返回。
- NSURLErrorUserCancelledAuthentication
- NSURLErrorUserCancelledAuthentication
Returned when an asynchronous request for authentication is cancelled by the user.
当用户取消异步身份验证请求时返回。
- NSURLErrorUserAuthenticationRequired
- NSURLErrorUserAuthenticationRequired
Returned when authentication is required to access a resource.
当访问资源需要身份验证时返回。
- NSURLErrorZeroByteResource
- NSURLErrorZeroByteResource
Returned when a server reports that a URL has a non-zero content length, but terminates the network connection “gracefully” without sending any data.
当服务器报告 URL 的内容长度不为零时返回,但“优雅地”终止网络连接而不发送任何数据。
- NSURLErrorCannotDecodeRawData
- NSURLErrorCannotDecodeRawData
Returned when content data received during an NSURLConnection request cannot be decoded for a known content encoding.
当在 NSURLConnection 请求期间接收的内容数据无法为已知的内容编码进行解码时返回。
- NSURLErrorCannotDecodeContentData
- NSURLErrorCannotDecodeContentData
Returned when content data received during an NSURLConnection request has an unknown content encoding.
在 NSURLConnection 请求期间收到的内容数据具有未知的内容编码时返回。
- NSURLErrorCannotParseResponse
- NSURLErrorCannotParseResponse
Returned when a response to an NSURLConnection request cannot be parsed.
当无法解析对 NSURLConnection 请求的响应时返回。
- NSURLErrorInternationalRoamingOff
- NSURLErrorInternationalRoamingOff
Returned when a connection would require activating a data context while roaming, but international roaming is disabled.
当连接需要在漫游时激活数据上下文但禁用国际漫游时返回。
- NSURLErrorCallIsActive
- NSURLErrorCallIsActive
Returned when a connection is attempted while a phone call is active on a network that does not support simultaneous phone and data communication (EDGE or GPRS).
在不支持同时进行电话和数据通信(EDGE 或 GPRS)的网络上进行电话呼叫时尝试连接时返回。
- NSURLErrorDataNotAllowed
- NSURLErrorDataNotAllowed
Returned when the cellular network disallows a connection.
当蜂窝网络不允许连接时返回。
- NSURLErrorRequestBodyStreamExhausted
- NSURLErrorRequestBodyStreamExhausted
Returned when a body stream is needed but the client does not provide one. This impacts clients on iOS that send a POST request using a body stream but do not implement the NSURLConnection delegate method connection:needNewBodyStream.
当需要正文流但客户端不提供时返回。这会影响 iOS 上使用正文流发送 POST 请求但未实现 NSURLConnection 委托方法 connection:needNewBodyStream 的客户端。
- NSURLErrorFileDoesNotExist
- NSURLErrorFileDoesNotExist
Returned when a file does not exist.
当文件不存在时返回。
- NSURLErrorFileIsDirectory
- NSURLErrorFileIsDirectory
Returned when a request for an FTP file results in the server responding that the file is not a plain file, but a directory.
当对 FTP 文件的请求导致服务器响应该文件不是普通文件而是目录时返回。
- NSURLErrorNoPermissionsToReadFile
- NSURLErrorNoPermissionsToReadFile
Returned when a resource cannot be read due to insufficient permissions.
由于权限不足而无法读取资源时返回。
- NSURLErrorSecureConnectionFailed
- NSURLErrorSecureConnectionFailed
Returned when an attempt to establish a secure connection fails for reasons which cannot be expressed more specifically.
当尝试建立安全连接由于无法更具体表达的原因而失败时返回。
- NSURLErrorServerCertificateHasBadDate
- NSURLErrorServerCertificateHasBadDate
Returned when a server certificate has a date which indicates it has expired, or is not yet valid.
当服务器证书的日期表明它已过期或尚未有效时返回。
- NSURLErrorServerCertificateUntrusted
- NSURLErrorServerCertificateUntrusted
Returned when a server certificate is signed by a root server which is not trusted.
当服务器证书由不受信任的根服务器签名时返回。
- NSURLErrorServerCertificateHasUnknownRoot
- NSURLErrorServerCertificateHasUnknownRoot
Returned when a server certificate is not signed by any root server.
当服务器证书未由任何根服务器签名时返回。
- NSURLErrorServerCertificateNotYetValid
- NSURLErrorServerCertificateNotYetValid
Returned when a server certificate is not yet valid.
当服务器证书尚未有效时返回。
- NSURLErrorClientCertificateRejected
- NSURLErrorClientCertificateRejected
Returned when a server certificate is rejected.
当服务器证书被拒绝时返回。
- NSURLErrorClientCertificateRequired
- NSURLErrorClientCertificateRequired
Returned when a client certificate is required to authenticate an SSL connection during an NSURLConnection request.
在 NSURLConnection 请求期间需要客户端证书来验证 SSL 连接时返回。
- NSURLErrorCannotLoadFromNetwork
- NSURLErrorCannotLoadFromNetwork
Returned when a specific request to load an item only from the cache cannot be satisfied.
当无法满足仅从缓存加载项目的特定请求时返回。
- NSURLErrorCannotCreateFile
- NSURLErrorCannotCreateFile
Returned when NSURLDownload object was unable to create the downloaded file on disk due to a I/O failure.
当 NSURLDownload 对象由于 I/O 失败而无法在磁盘上创建下载的文件时返回。
- NSURLErrorCannotOpenFile
- NSURLErrorCannotOpenFile
Returned when NSURLDownload was unable to open the downloaded file on disk.
当 NSURLDownload 无法打开磁盘上下载的文件时返回。
- NSURLErrorCannotCloseFile
- NSURLErrorCannotCloseFile
Returned when NSURLDownload was unable to close the downloaded file on disk.
当 NSURLDownload 无法关闭磁盘上下载的文件时返回。
- NSURLErrorCannotWriteToFile
- NSURLErrorCannotWriteToFile
Returned when NSURLDownload was unable to write to the downloaded file on disk.
当 NSURLDownload 无法写入磁盘上下载的文件时返回。
- NSURLErrorCannotRemoveFile
- NSURLErrorCannotRemoveFile
Returned when NSURLDownload was unable to remove a downloaded file from disk.
当 NSURLDownload 无法从磁盘中删除下载的文件时返回。
- NSURLErrorCannotMoveFile
- NSURLErrorCannotMoveFile
Returned when NSURLDownload was unable to move a downloaded file on disk.
当 NSURLDownload 无法在磁盘上移动下载的文件时返回。
- NSURLErrorDownloadDecodingFailedMidStream
- NSURLErrorDownloadDecodingFailedMidStream
Returned when NSURLDownload failed to decode an encoded file during the download.
当 NSURLDownload 在下载过程中无法解码编码文件时返回。
- NSURLErrorDownloadDecodingFailedToComplete
- NSURLErrorDownloadDecodingFailedToComplete
Returned when NSURLDownload failed to decode an encoded file after downloading.
当 NSURLDownload 下载后无法解码编码文件时返回。
NSURLErrorAppTransportSecurityRequiresSecureConnection
NSURLErrorBackgroundSessionInUseByAnotherProcess
NSURLErrorBackgroundSessionRequiresSharedContainer
NSURLErrorBackgroundSessionWasDisconnected
NSURLErrorFileOutsideSafeArea
NSURLErrorAppTransportSecurityRequiresSecureConnection
NSURLErrorBackgroundSessionInUseByAnotherProcess
NSURLErrorBackgroundSessionRequiresSharedContainer
NSURLErrorBackgroundSessionWasDisconnected
NSURLErrorFileOutsideSafeArea