我有一个字典数组,其中有两个感兴趣的键对。一个密钥对是日期,另一个是“investpercent”,它的值经常变化。我想知道最后一次约会是哪一次
investpercent
已更新。因此,请考虑:
var importedRecords = [
["low": "1.0", "date": "2018-04-25", "objective": "2.0", "savings": "2.0", "high": "2.0", "expenses": "1.0", "investpercent": "3.0"],
["low": "1.0", "date": "2018-05-25", "objective": "2.0", "savings": "2.0", "high": "2.0", "expenses": "1.0", "investpercent": "3.0"],
["low": "1.0", "date": "2018-06-25", "objective": "2.0", "savings": "2.0", "high": "2.0", "expenses": "1.0", "investpercent": "4.0"],
["low": "1.0", "date": "2018-07-25", "objective": "2.0", "savings": "2.0", "high": "2.0", "expenses": "1.0", "investpercent": "4.0"],
["low": "1.0", "date": "2018-08-25", "objective": "2.0", "savings": "2.0", "high": "2.0", "expenses": "1.0", "investpercent": "5.0"],
["low": "2", "date": "2018-09-26", "objective": "2.0", "savings": "2.0", "high": "4", "expenses": "1.0", "investpercent": "5.0"]
]
现在,注意
投资百分比
var lastentry = importedRecords.suffix(1)
var lastdate: String = ""
for record in importedRecords {
if record["investpercent"] == lastentry["investpercent"] {
lastdate = record["date"]
}
}