2011-12-10 61 views
0

我開發了一個應用程序,每7分鐘從服務器下載並解析xml數據。後臺長時間運行的任務

我希望它在大多數時間在後臺工作,所以如果有任何更改,此應用程序可以發送本地通知。

我讀了蘋果的質量要求在長時間運行的後臺任務,並且沒有合適的類別:

For tasks that require more execution time to implement, you must request specific permissions to run them in the background without their being suspended. In iOS, only specific app types are allowed to run in the background: 

Apps that play audible content to the user while in the background, such as a music player app 
Apps that keep users informed of their location at all times, such as a navigation app 
Apps that support Voice over Internet Protocol (VoIP) 
Newsstand apps that need to download and process new content 
Apps that receive regular updates from external accessories 

有何意見?

+0

我可以知道爲什麼要每隔7分鐘從服務器下載xml的原因嗎? – aherlambang

+0

...如果有任何變化,這個應用程序可以發送本地通知 – Shmidt

回答

1

創建一個NSThread,而不是與睡眠無限循環,你會更好使用NSTimer。您可以使用timerWithTimeInterval來初始化它:invocation:repeats:然後將其安排在運行循環的後臺線程中。