gpt4 book ai didi

swift - 如何在 Swift 中多次显示通知?

转载 作者:行者123 更新时间:2023-11-28 13:02:16 25 4
gpt4 key购买 nike

有没有办法每 15 秒快速显示一次通知?我通过

检查过
notification.fireDate=NSDate(timeIntervalSinceNow: 15)

但它并不是每次都只显示一次,我们如何才能将它作为一个循环来实现?

最佳答案

您不能每 15 秒安排一次通知。通知之间的最短时间间隔为 1 分钟,这也不太可能需要。

var repeatInterval: NSCalendarUnit { get set }

Description The calendar interval at which to reschedule the notification. If you assign a calendar unit such as weekly (NSWeekCalendarUnit) or yearly (NSYearCalendarUnit), the system reschedules the notification for delivery at the specified interval. Note that intervals of less than one minute are not supported. The default value is 0, which means that the system fires the notification once and then discards it.

所以只需按如下方式设置:

notification.repeatInterval = .Minute

关于swift - 如何在 Swift 中多次显示通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33597087/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com