Background task is running only when iPhone is connected with xcode -


hi using following code background task works fine ,when iphone connected xcode , when ran app without connected xcode ,then background tasks won't work

- (void)applicationdidenterbackground:(uiapplication *)application  {     back=1.0f;      nsautoreleasepool *pool=[[nsautoreleasepool alloc] init];     nsrunloop *runloop=[nsrunloop currentrunloop];     timer=[nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(changecounter) userinfo:nil repeats:yes];     [runloop run];     [pool release];  } 

please why happening

have checked documentation background executation?

you should start task like:

- (void)applicationdidenterbackground:(uiapplication *)application {     uiapplication*    app = [uiapplication sharedapplication];      bgtask = [app beginbackgroundtaskwithexpirationhandler:^{         [app endbackgroundtask:bgtask];         bgtask = uibackgroundtaskinvalid;     }];      // start long-running task , return immediately.     dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{          // work associated task.          [app endbackgroundtask:bgtask];         bgtask = uibackgroundtaskinvalid;     }); } 

http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/backgroundexecution/backgroundexecution.html


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -