Search code examples
swiftgcdwebserver

unexpectedly found nil while unwrapping an Optional value


I put the m3u8 in GCDWebServer to play. When I use Wi-Fi, it is no problem. But using 4G, appears this problem.

enter image description here

enter image description here


Solution

  • I have already solved the problem.When I use 4 g, access to the dataServer!ServerURL is nil.My solution is to give it a local IP

     if davServer?.serverURL == nil {
                    serverAddress = NSURL.init(string: "http://localhost/playts.m3u8")!
                }else{
                   serverAddress = (davServer?.serverURL.URLByAppendingPathComponent(self.m3u8!))!
                }