Reputation: 399
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
Upvotes: 1
Views: 250
Reputation: 4731
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?
Upvotes: 1