我想从Realm结果
创建一个数组[0] SaveCalendar {
id = 1;
color = #F0C0DD;
date = 2018-04-11 14:05:00;
},
[1] SaveCalendar {
id = 2;
color = #EDBBB5;
date = 2018-04-12 13:07:00;
},
我想像这样转换它:[#F0C0DD : 2018-04-11 14:05:00 , #EDBBB5 : 2018-04-12 13:07:00]
答案 0 :(得分:0)
试试此代码
var calendarList = Array(realm.objects(SaveCalendar.self))
var strCalendarList = [[String:String]]()
for calender in calendarList {
strCalendarList.append(["\(calender.color)":"\(calender.date)"])
}
print(strCalendarList)
结果
[["#EDBBB5": "2018-04-11 14:05:00"], ["#EDBBB5": "2018-04-11 14:05:00"]]