let usedNum = deal.totalCount if usedNum != nil { self.info.text = "\(usedNum) used" } if let date = deal.expiryDate, infoText = self.info.text { if usedNum != nil { self.info.text = infoText + " | Expires \(date.month)/\(date.day)/\(date.year)" } else { self.info.text = infoText + "Expires \(date.month)/\(date.day)/\(date.year)" } }
==》
var infoParts = [String]() if let usedNum = deal.totalCount { infoParts.append("\(usedNum) used") } else { infoParts.append("NUM used") } if let date = deal.expiryDate { infoParts.append("Expires \(date.month)/\(date.day)/\(date.year)") } self.info.text = infoParts.joinWithSeparator(" | ")
时间: 2024-10-28 21:35:41