Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Create stack synchronously #31

Closed
bitomule opened this issue Oct 15, 2015 · 2 comments
Closed

Create stack synchronously #31

bitomule opened this issue Oct 15, 2015 · 2 comments
Labels

Comments

@bitomule
Copy link

Is it possible to create the stack synchronously? I create it in app delegate and need to use it before any controller is created. Is it possible?

@rcedwards
Copy link
Contributor

@bitomule It is not possible to create a SQLite backed CoreDataStack instance synchronously and this is by design. With SQLite backed stores it can take an indefinite amount of time to map your xcdatamodel into SQLite tables/rows, especially on first time launches or between model migrations.

Its is always a good practice to architect your app with the assumption that this could take a longer amount of time than you'd want to block the main thread.

In your case I would suggest doing one of two things:

  1. You can make the CoreDataStack dependency on your view controllers an optional that is set once the setup has called back to you. In this scenario you need to ensure you'r view controller has something to display while the CoreDataStack is absent.
  2. You can suspend setting up these initial view controllers within the AppDelegate until the stack has been created. A splash screen/spinner type of UI can be used here while the stack is being constructed.

@bitomule
Copy link
Author

Thanks, I'll try showing a loading screen while creating stack.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants