I'm trying to code part of a program that allows users to set up one or more alarms that will remind them to launch the application and do something at certain times of day.
I basically understand that I need to use local notifications, but I'm having a hard time coming up with the best way to represent a time of day in my application settings in the proper manner.
For example, I tried this sort of thing to represent 8:00 AM
[NSDate dateWithTimeIntervalSince1970:(8 * 60 * 60)]
But the problem is that this means 8 AM GMT and not in the local timezone, so when I pass this to NSDateFormatter I end up with 3:00AM for example in my time zone.
Basically I know I need to do something with NSCalendar
, NSDate
, and NSTimeInterval
, and perhaps NSDateComponents
but I can't seem to come up with the simplest approach to this that will allow me to calculate scheduling NSDates for iOS local notifications.
So I guess what this boils down to is, how do I represent 8:00 AM for example in the system timezone in such a way that NSDateFormatter will correctly format it as a local time?
Seems like I should be able to figure this out but maybe it's just too late in the evening....