我的游戏中有2个场景。主屏幕只有一个按钮,开始(单击该按钮可以将您带到另一个场景)以及一个带有游戏的场景。
由于某些原因,private func encyptCardDetails(data: Data){
guard let rsaKeytemp = String(bytes: data, encoding: String.Encoding.ascii) else{
print("No value for rsaKeyTemp")
return
}
rsaKey = rsaKeytemp
rsaKey = self.rsaKey.trimmingCharacters(in: CharacterSet.newlines)
rsaKey = "-----BEGIN PUBLIC KEY-----\n\(self.rsaKey)\n-----END PUBLIC KEY-----\n"
print("rsaKey :: ",rsaKey)
let myRequestString = "amount=\(amount)¤cy=\(getCurrency())"
let ccTool = CCTool()
var encVal = ccTool.encryptRSA(myRequestString, key: rsaKey)
encVal = CFURLCreateStringByAddingPercentEscapes(
nil,
encVal! as CFString,
nil,
"!*'();:@&=+$,/?%#[]" as CFString,
CFStringBuiltInEncodings.UTF8.rawValue) as String?
let urlAsString = "https://secure.ccavenue.com/transaction/initTrans"
let encryptedStr = String(format:"merchant_id=%@&order_id=%@&redirect_url=%@&cancel_url=%@&enc_val=%@&access_code=%@", CC_AVENUE_MERCHANTID, self.orderId, CC_AVENUE_REDIRECTURL, CC_AVENUE_REDIRECTURL, encVal!,CC_AVENUE_ACCESSKEY)
print("access_code=\(CC_AVENUE_ACCESSKEY)")
print("order_id=\(self.orderId)")
let myRequestData = encryptedStr.data(using: String.Encoding.utf8)
request = NSMutableURLRequest(url: URL(string: urlAsString)! as URL, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringCacheData, timeoutInterval: 30)
request?.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "content-type")
request?.setValue(urlAsString, forHTTPHeaderField: "Referer")
request?.httpMethod = "POST"
request?.httpBody = myRequestData
print("\n\n\nwebview :: ",request?.url as Any)
print("\n\n\nwebview :: ",request?.description as Any)
print("\n\n\nwebview :: ",request?.httpBody?.description as Any)
print("\n\n\nwebview :: ",request?.allHTTPHeaderFields! as Any)
let session = URLSession(configuration: URLSessionConfiguration.default)
print("session",session)
session.dataTask(with: request! as URLRequest) {
(data, response, error) -> Void in
if let response = response as? HTTPURLResponse, 200...299 ~= response.statusCode{
guard let data = data else{
print("No value for data")
return
}
// Create the delay here
DispatchQueue.main.asyncAfter(deadline: .now()+1.0, execute: {
self.viewWeb.loadRequest(self.request! as URLRequest)
}
print("data :: ",data)
}else{
print("into else")
showAlertWithTitleWithMessage(message: "Unable to load webpage currently, Please try again later.")
}
}.resume()
}
在第二个场景中被调用,即使尚未加载。
Update()