I am using a webservice to fetch data from the server. It is working fine when the device is unlocked. But while loading data, if I lock the iPhone, and unlock it, I receive empty data.

Someone provide me a solution to avoid this problem?

有帮助吗?

解决方案

If you lock the phone, the app is backgrounded. When you wake it back up, the connection will have been cancelled and your data incomplete (depending on what you do) or no data at all.

I'd suggest you read up on background loading of data with the URL loading system and use that: https://developer.apple.com/library/iOS/documentation/Cocoa/Conceptual/URLLoadingSystem/Articles/UsingNSURLSession.html

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top