0
我想使地圖數據嵌套字典奇怪的行爲
代碼:
class figures {
var maps : [NSDictionary]
init() {
self.maps = [
[
"map" : [
[ "x" : -0.5, "y" : -0.5]
],
"color" : UIColor.redColor()
],
[
"map" : [
[ "x" : 0, "y" : 0], [ "x" : 0, "y" : -1], [ "x" : -1, "y" : 0], [ "x" : -1, "y" : -1]
],
"color" : UIColor.blueColor()
],
[
"map" : [
[ "x" : 0, "y" : -0.5], [ "x" : -1, "y" : -0.5]
],
"color" : UIColor.yellowColor()
]
]
}
}
這段代碼是有效的,但我想這本詞典添加1個數字,如:
[
"map" : [
[ "x" : -1, "y" : -0.5], [ "x" : 0.5, "y" : -0.5], [ "x" : -0.5, "y" : -0.5]
],
"color" : UIColor.cyanColor()
]
,現在我得到了以下錯誤:
Could not find an overload for '-' that accepts the supplied arguments
但如果在最後的dict 0.5 -0.5替換爲X它再次有效
[
"map" : [
[ "x" : -1, "y" : -0.5], [ "x" : 0.5, "y" : -0.5], [ "x" : 0.5, "y" : -0.5]
],
"color" : UIColor.cyanColor()
]
發生了什麼事?任何人幫助
請顯示給出錯誤的代碼,因爲您描述的圖可能會插入到許多位置。 – Kirsteins 2014-10-28 11:15:34
錯誤位於self.map聲明 – 2014-10-28 14:12:37
顯示您分配給'self.maps'的所有文字。 – Kirsteins 2014-10-28 14:16:48