安排任务以在 iOS 中执行方法 [英] Schedule Tasks to execute methods in iOS

查看:57
本文介绍了安排任务以在 iOS 中执行方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 iOS 中安排任务以根据一天中的时间和一天执行一个方法.例如,我想每天晚上 10 点执行 startMonitorRegion,早上 10 点执行 stopMonitorRegion.我不想发送本地通知来提醒用户,它需要对用户透明.

I would like to schedule tasks in iOS to execute a method depending on the time of the day and the day. For example, I want to execute startMonitorRegion every day at 10pm and stopMonitorRegion at 10am. I don't want to send a local notification to alert the user, it needs to be transparent for the user.

无论如何要使用 NSTimer 吗?该应用程序将在后台运行.

Is anyway to do it using NSTimer? The app will be in background.

推荐答案

您可以将本地通知用于此目的.

You can utilize Local notifications for this purpose.

只需为某个日期/时间安排本地通知.一旦用户打开您的应用程序,您就可以执行所需的任务..

Just schedule local notification for some date/time. and once user open your app you can perform the required task..

这篇关于安排任务以在 iOS 中执行方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆