【发布时间】:2016-06-14 14:47:21
【问题描述】:
我从 tax_ncurrency 中的键“Value”中得到了“16”的值。我正在使用 Alamofire 处理 json,但我无法将其分配给我的标签:productTax
["data": (
{
"tax_n_currency" = {
Value = 16;
Variable = Tax;
};
},
{
"tax_n_currency" = {
Value = USD;
Variable = Currency;
};
}
)]
我的请求。
Alamofire.request(.GET, url!, parameters: ["accesskey":223344666]).responseJSON { (request, response, result) in
let json = result.value as! [String:AnyObject]
print(json)
let data = json["data"] as! [AnyObject]
//print(mm)
let taxnCurrency = data[0]["tax_n_currency"] as! NSDictionary
print(taxnCurrency)
if let tax = taxnCurrency["Value"]?.intValue{
self.productTax.text = "\(tax) %"
print(tax)
}
}
【问题讨论】:
-
let tax = json["Value"]?.intValue=>let tax = taxnCurrency["Value"]?.intValue? -
我已经注意到一个犯了这个错误,但它说太用“!”当我再次尝试时(所以基本上是 2 次展开)