redned redned - 6 months ago 56
iOS Question

Is it possible to make an alarm using NSTimer and UIDatepicker?

I have an app which plays some ambient noises. I have fitted it with a sleep timer and a local notifier which work fine, but the notifier will only fire when the app is in the background.

I would like to be able to fit a standard alarm clock that the user can set using the date picker, ie, the user picks 07:15 am on the date picker and this triggers a sound being played at this time. Can this be done?


I would stick with local notifications, you can listen for them while the app is active using

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

And to play your sound you can set the soundName property of your notification.