2015-06-26 166 views
0

我的自定義功能如下:'_' 是無法轉換爲StringLiteralConvertible

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

回答

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 
} 
+0

當然,什麼是愚蠢的錯誤:-) +1給你。 –

相關問題