what is the best method to implement a alarm with my iPhone app? NSTimer, or DatePicker? help me with some code !
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think you will need to use DatePicker.
Also you can use UILocalNotifications, which could be a great help.
You can pick Alarm date from DatePicker and then set it as
fireDatefor your UILocalNotification.For more information you may want to refer to UIDatePicker Class Reference and UILocalNotification Class Reference
EDIT:
Refer to this post and answer of Ole Begemann under it:
How to implement an alarm with iPhone SDK 4.0
Also refer to this sample code, I have not checked it personally but may be it could help you:
iDharmaClock
EDIT-2: Solution about playing custom sounds in Local notifications
Add any file in your iPhone app’s Resources and then use the below code:
Let us suppose that
notificationis an object of typeUILocalNotification.If this doesn’t work initially then you may refer to this post and there in refer to answer of Noah Witherspoon. That tells us to use sound file of the correct format (i.e. either Linear PCM or IMA4).
Choose custom sound for local notifications
Hope this helps.
Let me know if you need more help.