I am trying to work through some of the AppsAmuck tutorials but they mostly seem to use code that Apple has deprecated. For example, there is a function that is called by a timer every second that looks like this:
NSDate *now = [NSDate date];
int hour = 23 - [[now dateWithCalendarFormat:nil timeZone:nil] hourOfDay];
int min = 5...
In order to measure the time duration while my app is running, as well as the time that passed while my app was idle in the background, I need a reference clock that is not altered by the user changing the Time+Date of his calendar clock.
I can not rely on NSDate because that can be changed by the user while my app is in the background ...
I'm trying to use an NSDate variable captured in another method. After much reading and searching I thought I found the answer on this site: http://www.everydayone.com/2009/08/nsdate-as-global-variable/. I first tried declaring the variables in the AppDelegate.h as specified in the article. The result was 2 failures in theViewController ...
NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.sss"];
self.date = [dateFormatter dateFromString:dateString];
the code works fine with this string
"2007-06-10 06:31:54.935"
but doesn't work with this one (it returns nil if the time is set to 0):
"20...
I currently display time in 24h format, because it's the easiest thing for me to do right now with the data I have.
I get the time in "minutes since midnight", so for example, 07:00 or 7:00 a.m is "420" and 21:30 or 9:30 p.m is "1290" and so on.
[NSString stringWithFormat:@"%02d:%02d - %02d:%02d", (open / 60), (open % 60), (close / 60)...
With the iOS SDK I need to find an easy and secure way to see if an NSDate is today, yesterday, tomorrow. What I'm looking for is something like this in pseudo code:
NSDate *myDate = someDate;
if ([myDate isTomorrow]) {
NSLog("Tomorrow");
}
How would you solve it?
...