특정 시간 간격마다 웹 서버에서 데이터를 가져 오는 하나의 iPhone 응용 프로그램을 만들고 싶습니다. 심지어 applilcation 백그라운드에서 실행중인 경우에도.객관적인 - C 웹 서버에서 데이터 가져 오기
모든 perticuler 시간 간격 후에 데이터를 가져 오려고합니다. 하지만 응용 프로그램이 백그라운드로 들어갈 때. NStimer는 이벤트를 위장 할 수 없습니다. 웹 서비스에 전화를 걸 수는 없습니다.
는 또한
NSTimeInterval delay_in_seconds = 3.0;
dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, delay_in_seconds * NSEC_PER_SEC);
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_after(delay, queue, ^{
// perform your background tasks here. It's a block, so variables available in the calling method can be referenced here.
// now dispatch a new block on the main thread, to update our UI
dispatch_async(dispatch_get_main_queue(), ^{
[self setBackgoundProcess];
});
});
하지만 여전히 내가 데이터를 가져올 수없는 나는 다음과 같은 코드를 사용하여 그랜드 센트럴 디스패치 (GCD)를 사용하여 호출하는 웹 서비스가있다. 응용 프로그램이 백그라운드에서 실행되면 작동하지 않습니다.
사전에 감사
아이폰
에 배경에서 웹 서비스를 호출 할 수있는 유장가있다.