2017-05-09 39 views

回答

0

我已經解決了這個問題。當我用4個克,訪問數據服務器!SERVERURL。我的解決辦法就是給它一個本地IP

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

你正在代碼中強制展開m3u8。如果這是nil,您將遇到問題。你在說,當你使用!強制解包時,它永遠不會成爲零。

您可以使用if let方法,或者您也可以測試nil

// Are you sure dataServer isn't nil too here? 
if let serverAddress = dataServer!.serverURL.URLByAppendingPathComponent(self.m3u8) { 
    //Should be safe 
} 

或者

if m3u8 == nil { 
    print("m3u8 is nil") 
    return 
} 
相關問題