<分区>
我正在制作的应用程序有 5 天的试用期。请告诉我什么是显示警报或试用期结束后的最佳方式。我想使用耗电量更少且效率更高的方法。以下是两个想法。
计时器:
Let fiveDays = 5 * 24 * 60 * 60
Timer.scheduledTimer(withTimeInterval: fiveDays, repeats: false, block: { (timer) in print("Hi!")})
调度队列
Let fiveDays = 5 * 24 * 60 * 60
DispatchQueue.main.asyncAfter(deadline: .now() + fiveDays, execute: {
self.functionToCall()
})
请建议:
- What is the best approach? Is it Timer or DispatchQueue
- Why is it the best approach?