我们假设你有
var arr = ["con1","con2","con3"]
然后当你打开应用程序
if let date2 = UserDefaults.standard.object(forKey: "date") as? Date { var time = Date().timeIntervalSince(date2) var res = Int(time.truncatingRemainder(dividingBy:86400))! // 86400 = 24hrs * 60 * 60 if res < arr.count { textView.text = arr[res] } } else { // first open textView.text = arr.first! UserDefaults.standard.set(Date(),forKey:"date") }