[英]NotificationCenter registered selector is not called
I currently have this code below to see if the day has elapsed, but it doesn't seem to be working. 我目前在下面有此代码,以查看是否已经过去了一天,但似乎无法正常工作。 Have I coded this correctly?
我编码正确吗?
NotificationCenter.default.addObserver(self, selector:"calendarDayDidChange:", name:NSNotification.Name.NSCalendarDayChanged, object:nil)
func calendarDayDidChange(notification : NSNotification) {
// code to respond to notification
}
I think the way you registered observer is not correct. 我认为您注册观察员的方式不正确。 Please try the below and check.
请尝试以下检查。
NotificationCenter.default.addObserver(self, selector:#selector(self.calendarDayDidChange(notification:)), name:NSNotification.Name.NSCalendarDayChanged, object:nil)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.