NSURLConnection Error Code -1100

Viewed 22046

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:

NSURLConnection finished with error - code -1100  

Can anybody help? My current Swift Code is:

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.

3 Answers

-1100 means NSURLErrorFileDoesNotExist. And you are accessing a local file, print the URL's absoluteString to check the path is good for that file.

Short description for all NSURLRequest error codes: URL Loading System Error Codes

  • NSURLErrorUnknown

Returned when the URL Loading system encounters an error that it cannot interpret.

  • NSURLErrorCancelled

Returned when an asynchronous load is canceled.

  • NSURLErrorBadURL

Returned when a URL is sufficiently malformed that a URL request cannot be initiated

  • NSURLErrorTimedOut

Returned when an asynchronous operation times out.

  • NSURLErrorUnsupportedURL

Returned when a properly formed URL cannot be handled by the framework.

  • NSURLErrorCannotFindHost

Returned when the host name for a URL cannot be resolved.

  • NSURLErrorCannotConnectToHost

Returned when an attempt to connect to a host has failed.

  • NSURLErrorDataLengthExceedsMaximum

Returned when the length of the resource data exceeds the maximum allowed.

  • NSURLErrorNetworkConnectionLost

Returned when a client or server connection is severed in the middle of an in-progress load.

  • NSURLErrorDNSLookupFailed

See NSURLErrorCannotFindHost

  • NSURLErrorHTTPTooManyRedirects

Returned when a redirect loop is detected or when the threshold for number of allowable redirects has been exceeded (currently 16).

  • NSURLErrorResourceUnavailable

Returned when a requested resource cannot be retrieved.

  • 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.

  • 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.

  • NSURLErrorBadServerResponse

Returned when the URL Loading system receives bad data from the server.

  • NSURLErrorUserCancelledAuthentication

Returned when an asynchronous request for authentication is cancelled by the user.

  • NSURLErrorUserAuthenticationRequired

Returned when authentication is required to access a resource.

  • 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.

  • NSURLErrorCannotDecodeRawData

Returned when content data received during an NSURLConnection request cannot be decoded for a known content encoding.

  • NSURLErrorCannotDecodeContentData

Returned when content data received during an NSURLConnection request has an unknown content encoding.

  • NSURLErrorCannotParseResponse

Returned when a response to an NSURLConnection request cannot be parsed.

  • NSURLErrorInternationalRoamingOff

Returned when a connection would require activating a data context while roaming, but international roaming is disabled.

  • 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).

  • NSURLErrorDataNotAllowed

Returned when the cellular network disallows a connection.

  • 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.

  • NSURLErrorFileDoesNotExist

Returned when a file does not exist.

  • 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.

  • NSURLErrorNoPermissionsToReadFile

Returned when a resource cannot be read due to insufficient permissions.

  • NSURLErrorSecureConnectionFailed

Returned when an attempt to establish a secure connection fails for reasons which cannot be expressed more specifically.

  • NSURLErrorServerCertificateHasBadDate

Returned when a server certificate has a date which indicates it has expired, or is not yet valid.

  • NSURLErrorServerCertificateUntrusted

Returned when a server certificate is signed by a root server which is not trusted.

  • NSURLErrorServerCertificateHasUnknownRoot

Returned when a server certificate is not signed by any root server.

  • NSURLErrorServerCertificateNotYetValid

Returned when a server certificate is not yet valid.

  • NSURLErrorClientCertificateRejected

Returned when a server certificate is rejected.

  • NSURLErrorClientCertificateRequired

Returned when a client certificate is required to authenticate an SSL connection during an NSURLConnection request.

  • NSURLErrorCannotLoadFromNetwork

Returned when a specific request to load an item only from the cache cannot be satisfied.

  • NSURLErrorCannotCreateFile

Returned when NSURLDownload object was unable to create the downloaded file on disk due to a I/O failure.

  • NSURLErrorCannotOpenFile

Returned when NSURLDownload was unable to open the downloaded file on disk.

  • NSURLErrorCannotCloseFile

Returned when NSURLDownload was unable to close the downloaded file on disk.

  • NSURLErrorCannotWriteToFile

Returned when NSURLDownload was unable to write to the downloaded file on disk.

  • NSURLErrorCannotRemoveFile

Returned when NSURLDownload was unable to remove a downloaded file from disk.

  • NSURLErrorCannotMoveFile

Returned when NSURLDownload was unable to move a downloaded file on disk.

  • NSURLErrorDownloadDecodingFailedMidStream

Returned when NSURLDownload failed to decode an encoded file during the download.

  • NSURLErrorDownloadDecodingFailedToComplete

Returned when NSURLDownload failed to decode an encoded file after downloading.

  • NSURLErrorAppTransportSecurityRequiresSecureConnection

  • NSURLErrorBackgroundSessionInUseByAnotherProcess

  • NSURLErrorBackgroundSessionRequiresSharedContainer

  • NSURLErrorBackgroundSessionWasDisconnected

  • NSURLErrorFileOutsideSafeArea

Related