Я поставил ваш код и есть только одна ошибка
То есть priceArray
должно быть filteredPriceArr
var filteredPriceArr = [0.0, 50.0, 100.0, 150.0]
var priceDict:[String:String] = [:]
for (index,item) in filteredPriceArr.enumerated() {
print(index)
print(filteredPriceArr.count)
if index + 1 != filteredPriceArr.count {
priceDict.updateValue("\(filteredPriceArr[index + 1])", forKey: "\(filteredPriceArr[index])")
}
}
print(priceDict)
здесь вывод
["0.0": "50.0", "100.0": "150.0", "50.0": "100.0"]
Вы не можете получить его в следующем порядке, как вы упоминали в вопросе
["0.0": "50.0", "50.0": "100.0", "100.0": "150.0"]
Словарь не может быть отсортирован !!