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(" | ")