iOS, best time to call Core Data queries on app start

68 views Asked by At

My app has Background App Refresh when it receives a Push Notification where it fetches data from the server and stores using Core Data, now I need to process the data when the App is becomes active again. So, I tried the fetch query when -(void)applicationDidBecomeActive:(UIApplication *)application is called to get the data.

But, if I directly query the tables immediately, the query returns 0 objects if the App is in stopped state. I guess the Core Data connectors are not prepared by the time I call the query. I am sure that the data is saved in the tables as if I make the query using dispatch_after 2 secs , I get the complete data.

I do not want to make the Query on viewDidLoad/viewDidAppear cause, it is not necessary that these will be called when the app goes becomes active from non active state.

0

There are 0 answers