Ios 由于未捕获异常而终止应用程序';NSInvalidArgumentException';,原因:'-[\uu NSCFTimer copyWithZone:]:发送到实例的选择器无法识别

Ios 由于未捕获异常而终止应用程序';NSInvalidArgumentException';,原因:'-[\uu NSCFTimer copyWithZone:]:发送到实例的选择器无法识别,ios,swift,nsdate,nstimer,uicollectionviewcell,Ios,Swift,Nsdate,Nstimer,Uicollectionviewcell,所以我读了其他关于标题中错误的问题,我尝试了他们的解决方案,但它们对我不起作用 在viewDidLoad()中,我有两个计时器: dayCountTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: #selector(DateMenuViewController.dayCount(_:)), userInfo: nil, repeats: true) daySinceTimer = NSTimer.s

所以我读了其他关于标题中错误的问题,我尝试了他们的解决方案,但它们对我不起作用

viewDidLoad()
中,我有两个计时器:

dayCountTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: #selector(DateMenuViewController.dayCount(_:)), userInfo: nil, repeats: true)
daySinceTimer = NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: #selector(DateMenuViewController.daysSinceOrUntil(_:)), userInfo: nil, repeats: true)
他们称这两种方法为:

// For dayCountLabel.text
func dayCount (dayCount: String) -> String{
    let day = dayCount
    let dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "dd MMMM yyyy hh:mm a"
    let date1: NSDate = dateFormatter.dateFromString(day)!
    let diffDateComponents = NSCalendar.currentCalendar().components([NSCalendarUnit.Day], fromDate: date1, toDate: date2, options: NSCalendarOptions.init(rawValue: 0))
    let difference = String("\(abs(diffDateComponents.day))")
    return difference
}

// For daySinceOrUntilLabel.text
func daysSinceOrUntil (daySince: String) -> String {
    let day = daySince
    let dateFormatter = NSDateFormatter()
    dateFormatter.dateFormat = "dd MMMM yyyy hh:mm a"
    let date1: NSDate = dateFormatter.dateFromString(day)!
    let diffDateComponents = NSCalendar.currentCalendar().components([NSCalendarUnit.Day], fromDate: date1, toDate: date2, options: NSCalendarOptions.init(rawValue: 0))

    if date1.compare(date2) == NSComparisonResult.OrderedDescending  {
        let text: String = "Days Until"
        return text
    } else if date1.compare(date2) == NSComparisonResult.OrderedAscending {
        let text: String = "Days Since"
        return text
    } else {
       return "Days"
    }

}
和在
UICollectionViewCell
中按以下方式使用

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

cell.dayCountLabel.text = dayCount(Globals.datesArray[indexPath.item])
cell.daySinceOrUntilLabel.text = daysSinceOrUntil(Globals.datesArray[indexPath.item])
我做错了什么?
谢谢

您的
dayCount
daysSinceOrUntil
函数的参数是NSTimer,而不是字符串。此外,从计时器调用的函数返回值也没有意义。似乎您想使用更新单元格的命令。在这种情况下,您需要编写另一个函数来更新单元格。您不能使用这些函数。但是,我需要这些函数每秒更新一次?这些函数返回您在单元格中显示的值。它们不会更新单元格。您需要编写一个新函数来获取所有当前可见的单元格,然后调用这些函数来获取新值,然后更新单元格。这就是计时器需要执行的函数。你能给我一个如何实现的例子吗?
dayCount
daysSinceOrUntil
函数的参数是一个NSTimer,而不是字符串。此外,从计时器调用的函数返回值也没有意义。似乎您想使用更新单元格的命令。在这种情况下,您需要编写另一个函数来更新单元格。您不能使用这些函数。但是,我需要这些函数每秒更新一次?这些函数返回您在单元格中显示的值。它们不会更新单元格。您需要编写一个新函数来获取所有当前可见的单元格,然后调用这些函数来获取新值,然后更新单元格。这是定时器需要执行的功能。你能给我一个如何实现的例子吗?