【问题标题】:'_' is not convertible to StringLiteralConvertible'_' 不能转换为 StringLiteralConvertible
【发布时间】:2023-03-22 03:50:01
【问题描述】:

我的自定义函数如下:

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
}

【问题讨论】:

    标签: swift2 xcode7-beta2


    【解决方案1】:

    你需要使用冒号而不是等号:

    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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多