Question

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?

Était-ce utile?

La solution

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top