我是android编程的新手。我正在尝试创建一个Currency Converter应用程序,该应用程序有两个下拉菜单,其中两种货币的列表中的项相同。我想要这样做,以便当用户从FROM货币中选择一个选项时,该选项会自动从TO Currency列表中消失。我试图做些事情来查看Google搜索的线索,但是它仅对其中一种有效。 我该怎么办??
答案 0 :(得分:0)
尝试将 do {
guard let receipt = Bundle.main.getReceiptData()?.base64EncodedString() else { return }
let requestDictionary = ["receipt-data": receipt]
guard JSONSerialization.isValidJSONObject(requestDictionary) else {
print("requestDictionary is not valid JSON")
return
}
let requestData = try JSONSerialization.data(withJSONObject: requestDictionary)
let validationURLString = "https://sandbox.itunes.apple.com/verifyReceipt"
guard let validationURL = URL(string: validationURLString) else {
print("the validation url could not be created, unlikely error")
return
}
let session = URLSession(configuration: URLSessionConfiguration.default)
var request = URLRequest(url: validationURL)
request.httpMethod = "POST"
request.cachePolicy = URLRequest.CachePolicy.reloadIgnoringCacheData
let task = session.uploadTask(with: request, from: requestData) { (data, response, error) in
if let data = data , error == nil {
do {
let appReceiptJSON = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
if let dict = appReceiptJSON as? NSDictionary {
print(dict["last_receipt_info"]!) // nil value ????
}
}catch {
print("JSON serialization failed with error: \(error.localizedDescription)")
}
} else {
print("Upload receipt data but something went wrong. Error: \(error?.localizedDescription)")
}
}
task.resume()
} catch let error as NSError {
print("JSON serialization failed. Error: \(error.localizedDescription)")
}
替换为toCurrencyList.remove(position)