iPhone Long Running Task Test 결과

didFinishLaunchingWithOption에서 Location Delegate를 추가하고 Background Task를 실행한 결과

- (void)applicationDidEnterBackground:(UIApplication *)application

{

? ? UIApplication*? ? app = [UIApplication sharedApplication];

? ??longRunTask =? [app beginBackgroundTaskWithExpirationHandler:^{

? ? //do nothing

? ? }];

}

#pragma mark – LocationDelegate

- (void) geoHeadingUpdated:(CLHeading *)head err:(NSInteger)nErrorCode {

[DCUtilities appendToLog:@"Updating Heading\n"];

return;

}

 

- (void) geoLocationUpdated:(CLLocation *)location err:(NSInteger)nErrorCode {

[DCUtilities appendToLog:@"Updating Location\n"];

return;

}

Location과 ?Heading이 바뀔때 마다 자동으로 ?callback이 들어와 iphone app directory에 로그를 기록하도록 하였으나.. 10분에 모두 종료되어 더이상 로그가 생성되지 않았음.

iOS Background Long Running Task

(void)applicationDidEnterBackground:(UIApplication *)application
{
UIApplication* ? ?app = [UIApplication sharedApplication];

longRunTask =??beginBackgroundTaskWithExpirationHandler:^{

// If you’re worried about exceeding 10 minutes, handle it here

[app endBackgroundTask:bgTask];
longRunTask = UIBackgroundTaskInvalid;

}];

count=0;

theTimer=[NSTimer scheduledTimerWithTimeInterval:60.0f

target:self?selector:@selector(increment)

userInfo:nil?repeats:YES];

}

//- (void)increment {

if (count==1000) {

[theTimer invalidate];

[theTimer release];

[[UIApplication sharedApplication] endBackgroundTask:longRunTask];

longRunTask = UIBackgroundTaskInvalid;

} else {

[self callServerPage:@"parameters"];

count++;

}

}

Test 결과는 다음회에…