1

My application has two sets of icons, one for day and one for night. What kind of if-then statement can I use to tell my app that if the time is later than 8PM-7AM.. do this action and if it is between 7AM-8PM.. do a different action?

Thanks

Dan Hoerst
  • 6,222
  • 2
  • 38
  • 51
Jon Sullivan
  • 399
  • 2
  • 5
  • 11
  • See if this helps: http://stackoverflow.com/questions/4081588/nsdate-right-way-to-work-with-time-of-day – KK. Feb 01 '13 at 02:48

1 Answers1

1

make a day and night enum or bool ivar

When your app is launching , you can get the current time .And then you can calc whether it is day or night , and then set the enum.

Then if it is day now, you should calc the timeInterval from now to 8PM named timeInterval1, then make a NSTimer to invocation your method to change the enum to night. The delay time is timeInterval1.

- (void)yourmethod
{
    if(enum == day)
    {

    }
    else
    {
    }
}

More info , you can see : How to create thread to checking time?

Community
  • 1
  • 1
Guo Luchuan
  • 4,729
  • 25
  • 33