I have to store some data into database after downloading it from server,I have succesfully downloaded the data ,but when i go to update it into sqlite database it takes time. In that case if user keeps the app is background and after sometimes user brings back the app in foreground then after few minutes it got crashed.
When user brings back the app in foreground then it takes high time to load the same screen where user has left it,and before the screen appears app got crashed.
Please help me on this....how can I keep this process running in background as well as foreground without any issues.
[self performSelectorInBackground:@selector(dataBaseUpdateMethod:) withObject:dictForUpdatingTheDatabase];
Where, dataBaseUpdateMethod will be the method which updates the database & dictForUpdatingTheDatabase is the NSDictionary Object (or say any other object of any type).
Hope this helps.
update your sqlite database in a background thread (using
if you are updating it in main thread in that case when user trying to app in foreground then application main thread is busy to complete your update DB task and not able to load the application and cause a crash.
[self performSelectorInBackground:@selector(updateDB:) withObject:dictionary];