Domanda

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?

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top