我正在尝试使用 Objects(Array) 和相应的键初始化字典。我正在崩溃,它说[NSDictionary initWithObjects:forKeys:]: count
对象(12)与键数(1)不同“。不确定我在这里缺少什么。有人可以帮忙吗?
下面是我的代码。
let df = DateFormatter()
var months = [Any]()
for monthIndex in 1...12 {
months.append(df.monthSymbols[monthIndex - 1])
}
let monthDictionay = NSDictionary.init(objects: months, forKeys: ["values" as NSCopying])
它在最后一行代码中崩溃。
以下是我想要实现的
我的monthDictionary应该有
values = (
January,
February,
March,
April,
May,
June,
July,
August,
September,
October,
November,
December
);