发送到iTunes Connect后代码更改

时间:2017-10-03 17:42:03

标签: ios swift itunesconnect testflight

当我们安装app时,将这段代码包含在我的iPhone上,应用程序正在运行...... 然后当我们将它发送到iTunes Connect进行测试(存档 - >导出和app loader)时,应用程序不会登录到服务器... 因为这个代码
 while!RequestCommplet {} 应用程序忽略了while ...

登录功能:

 func GetToken1(_ body:String?) -> (StatusCode:Int?,RetData:TokenFields?) {

   let token = TokenFields()
    var statusCode : Int! = 0
    var RequestCommplet = false

    let requestURL: URL = URL(string: domainName+"token")!
    //  let urlRequest: NSMutableURLRequest = NSMutableURLRequest(url: requestURL)
    var urlRequest = URLRequest(url: requestURL)
     let session = URLSession.shared       
    urlRequest.httpMethod = "POST"

    let bodyData = body!.toEnglishNumber.data(using: String.Encoding.utf8,allowLossyConversion:true)!       

    urlRequest.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")

    urlRequest.httpBody = bodyData

    let task = session.dataTask(with: urlRequest, completionHandler: {(data, response, error) -> Void in

        if response != nil {
           statusCode = (response as! HTTPURLResponse).statusCode
        }
        else{
            return
        }
        print(statusCode)
        if statusCode == 200 {
            do{

                let  ReturnData = try JSONSerialization.jsonObject(with: data!, options:JSONSerialization.ReadingOptions()) as? NSDictionary

                print (ReturnData ?? "error")


                token.ProvinceName = ReturnData!.valueToString(key: "ProvinceName")

                userToken = token
            }
            catch
            {
                userToken = nil
                print("Error with Json")

            }//do-catch

        }//if
        else{
            userToken = nil

        }

       RequestCommplet = true

    })
    task.resume()



    while !RequestCommplet {    }


    return (statusCode , token)



}//GetToken1

0 个答案:

没有答案