Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make my application run in background?
    primarykey
    data
    text
    <p>I am developing an alarm application. I use NSTimer in my application. The timer works just fine. But when I minimize the application, the timer stops working. How to make it work while the application is closed or minimized?</p> <p>Here is my code </p> <pre><code>- (void) alarmSaveButtonAction:(id)sender { timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(onTimerEvent) userInfo:nil repeats:YES]; } -(void)onTimerEvent { NSLog(@"saravanan"); NSDate *now = [NSDate new]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateFormat = @"hh:mm:ss a"; [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]]; NSLog(@"The Current Time is %@",[dateFormatter stringFromDate:now]); NSString *string2 = [NSString stringWithFormat:[dateFormatter stringFromDate:now]]; NSLog(@"currenttime %@", string2); [dateFormatter release]; Resource *resourceLoader = [[Resource alloc] init]; NSDictionary *prefDic = [resourceLoader getPlistDataAsDictionary:@"preference"]; NSDate *selectedDateTime = [[NSDate alloc]init]; selectedDateTime = [prefDic objectForKey:@"alarmtime"]; NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init]; dateFormatter1.dateFormat = @"hh:mm:ss a"; [dateFormatter1 setTimeZone:[NSTimeZone systemTimeZone]]; NSLog(@"saravanan date %@",[dateFormatter1 stringFromDate:selectedDateTime]); NSString *string1 = [NSString stringWithFormat:[dateFormatter1 stringFromDate:selectedDateTime]]; NSLog(@"currenttime %@", string1); [dateFormatter1 release]; if ([string1 isEqualToString:string2]) { NSLog(@"alarm scheduld"); [self scheduledNotification]; [timer invalidate]; timer = nil; } } </code></pre> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload