xCode 7.1 + swift2.1 + iOS 9.0
Code below block the Xcode compile operation.
let dic_1:Dictionary<String,Int> = ["key":200]
print("dic_1---->\(dic_1)")
Has this happened to anyone ?How does this happen?
Thanks for correcting grammer.
I found that it's not the reason the code above.
My origin code is below:
let dic_1 = [
"status": 200,
"info": "1234",
"data":[
"st_id":"st_id",
"st_name":"radiant",
"address":"dire",
"longitude":"122.111",
"latitude":"123.000000",
"is_favorite":"0",
"score":"5",
"thumbnail":"www.baidu.com",
"comment_count":"45612",
"cert_img_url":"www.baidu.com",
"has_inspay":"1",
"has_car_discount":"1",
"has_groupon":"1",
"score_environment":"4.5",
"score_service":"5.0",
"score_oil":"5.0",
"type":"98",
"city":"SHENZHEN",
"show_price_discount":"1",
"is_support_invoice":"1",
"price":[
[
"oil_name":"95#",
"market_price":"6.23",
"sell_price":"6.00",
"wecar_price":"-100.00"
],
[
"oil_name":"95#",
"market_price":"6.23",
"sell_price":"6.00",
"wecar_price":"-100.00"
],
[
"oil_name":"95#",
"market_price":"6.23",
"sell_price":"6.00",
"wecar_price":"-100.00"
],
],
"promotions": [
"promotion1",
"promotion1",
"promotion1",
"promotion1"
],
"gpns":[
[
"gpn_id":"75642",
"gpn_name":"gpn_name",
"oil_type":"95",
"price":"180",
"sell_amount":"20000000",
"old_price":"200"
]
],
"discount_items":[
[
"desc":"It's a descrition.",
"disc_type":"1"
]
]
]
]
print("dic_1---->\(dic_1)")
Playground is running running,never figure out anything.So does this happen in iOS project.No error,just running.
You've got a complex nested structure for the data
key so Swift's type inference system failed. In my Xcode 7.1.1, it gives a "Type is ambiguous without more context" error.
Give the compiler a hint as to the data type:
let data: [String: Any] = [
"st_id":"st_id",
"st_name":"radiant",
"address":"dire",
"longitude":"122.111",
"latitude":"123.000000",
"is_favorite":"0",
"score":"5",
"thumbnail":"www.baidu.com",
"comment_count":"45612",
"cert_img_url":"www.baidu.com",
"has_inspay":"1",
"has_car_discount":"1",
"has_groupon":"1",
"score_environment":"4.5",
"score_service":"5.0",
"score_oil":"5.0",
"type":"98",
"city":"SHENZHEN",
"show_price_discount":"1",
"is_support_invoice":"1",
"price":[
[
"oil_name":"95#",
"market_price":"6.23",
"sell_price":"6.00",
"wecar_price":"-100.00"
],
[
"oil_name":"95#",
"market_price":"6.23",
"sell_price":"6.00",
"wecar_price":"-100.00"
],
[
"oil_name":"95#",
"market_price":"6.23",
"sell_price":"6.00",
"wecar_price":"-100.00"
],
],
"promotions": [
"promotion1",
"promotion1",
"promotion1",
"promotion1"
],
"gpns":[
[
"gpn_id":"75642",
"gpn_name":"gpn_name",
"oil_type":"95",
"price":"180",
"sell_amount":"20000000",
"old_price":"200"
]
],
"discount_items":[
[
"desc":"It's a descrition.",
"disc_type":"1"
]
]
]
let dic_1: [String: Any] = [
"status": 200,
"info": "1234",
"data": data
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.