2017-09-03 125 views
0

找到這些文章中應用代理,但無法弄清楚他們如何幫助:部分Web服務調用

let task = session.dataTask(with: request, completionHandler: { 
     (data, response, error) in 

     if error == nil { 
      let result = String(data: data!, encoding: String.Encoding.utf8)! 
      if WebService.THETA_INVALID == result { 
       failure(LoginService.INVALID_MESSAGE) 
      } 
      else if WebService.THETA_UNVALIDATED == result { 
       failure(LoginService.UNVALIDATED_MESSAGE) 
      } 
      else { 
       let loginCredentials = LoginCredentials() 
       loginCredentials.username = user 
       loginCredentials.password = password 
       loginCredentials.authorization = result 
       success() 
      } 
     } else { 
      failure(error!.localizedDescription) 
     } 

    }) 
    task.resume() 

Understanding crash report (Partial apply...) in Swift Swift closure crashes when called as Objective-C block

我越來越部分在下面的代碼應用代理

錯誤object.failure包含「部分應用轉發器」,我不知道這意味着什麼。我試過Google搜索,它似乎與可選項有關,但大多數事情與Thunk有關?

任何人都可以幫我指出這個問題嗎?

回答

0

經過一番挖掘和敲打它,我注意到在右邊的窗格中的Xcode的東西:

nsurlsession NSURLConnection的HTTP加載失敗kcfstreamerrordomainssl -9802

我用Google搜索,發現這個這個問題:

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) in iOS 9 with Xcode 7.1

所以我在我的info.plist中創建了一個名爲App Transport Security Settings的字典,然後添加了一個名爲Allow Arbitrary Loads的密鑰。我將它設置爲布爾值true並重新運行我的測試,並且一切正常。

哎呀!