'_'不能转换为StringLiteralConvertible

时间:2015-06-26 14:26:50

标签: swift2 xcode7-beta2

我的自定义功能如下:

func mockDictionaryForLocation() -> [String: AnyObject] {
    let dictionary = [
        "id" = "1234",  //here I have an error from the title, why?
        "working_type" = "open_for_selected",
        "min_order_price" = 15,
        "specialization_breakfasts" = 1,
        "specialization_confectioneries" = 1,
        "specialization_dinners" = 0
    ]



    return dictionary
}

enter image description here

1 个答案:

答案 0 :(得分:4)

您需要使用冒号而不是等于:

func mockDictionaryForLocation() -> [String: AnyObject] {
    let dictionary = [
        "id": "1234",
        "working_type": "open_for_selected",
        "min_order_price": 15,
        "specialization_breakfasts": 1,
        "specialization_confectioneries": 1,
        "specialization_dinners": 0
    ]
    return dictionary
}