Reputation: 117
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.
Upvotes: 0
Views: 106
Reputation: 1249
Use This:
[self performSelectorInBackground:@selector(updateDB:) withObject:dictionary];
Upvotes: 0
Reputation: 3018
update your sqlite database in a background thread (using performSelectorInBackground
).
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.
Upvotes: 0
Reputation: 4208
Try this:
[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.
Upvotes: 3