这是我的模特课
class Messages: NSObject {
var id: Int?
var sender_id: Int?
var group_id: Int?
var message_type: Int?
var message: String?
var sent_time: Date?
var status: Int?
init(dictionary: [String: AnyObject]) {
super.init()
self.id = (dictionary["id"] as! NSString).integerValue
self.sender_id = (dictionary["sender_id"] as! NSString).integerValue
self.group_id = (dictionary["group_id"] as! NSString).integerValue
self.message_type = (dictionary["message_type"] as! NSString).integerValue
self.message = dictionary["message"] as! String?
let inputTime = dictionary["sent_time"] as! String?
let inputDateFormatter = DateFormatter()
let inputTimeZone = TimeZone(abbreviation: "UTC")
inputDateFormatter.timeZone = inputTimeZone
inputDateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let dateFromString = inputDateFormatter.date(from: inputTime!)
self.sent_time = dateFromString
self.status = (dictionary["status"] as! NSString).integerValue
}
}
这是我的模型类对象数组
var messages = [Messages]()
数组按升序排序
self.messages.sort(by: { $0.sent_time! < $1.sent_time! })
如何为日常创建不同的数组,这个数组存储在字典中,并在表格视图中查看,节日标题为foe day
看起来像这样