AddStorage not working? #191

Closed
opened 2025-12-29 15:26:25 +01:00 by adam · 4 comments
Owner

Originally created by @shift00 on GitHub (Dec 7, 2017).

I have small issue with my project and CoreStore. I need to have sqlite db on start of my app.
At didFinishLauchingWithOptions AppDelegate function I have this code:
let dataStack: DataStack = DataStack( CoreStoreSchema( modelVersion: "V1", entities: [ Entity<Entity1CSModel>("Entity1"), Entity<Entity2CSModel>("Entity2"), Entity<Entity3Model>("Entity3") ] ) )

CoreStore.defaultStack = dataStack

CoreStore.addStorage( SQLiteStore(fileName: "MyDatabase.sqlite"), completion: { (result) -> Void in print("test") } )

I noticed that completion handler is not called what throws the application when I want to create a new Entity1 entity.

Originally created by @shift00 on GitHub (Dec 7, 2017). I have small issue with my project and CoreStore. I need to have sqlite db on start of my app. At **didFinishLauchingWithOptions** AppDelegate function I have this code: `let dataStack: DataStack = DataStack( CoreStoreSchema( modelVersion: "V1", entities: [ Entity<Entity1CSModel>("Entity1"), Entity<Entity2CSModel>("Entity2"), Entity<Entity3Model>("Entity3") ] ) )` ` CoreStore.defaultStack = dataStack` `CoreStore.addStorage( SQLiteStore(fileName: "MyDatabase.sqlite"), completion: { (result) -> Void in print("test") } )` I noticed that completion handler is not called what throws the application when I want to create a new **Entity1** entity.
adam closed this issue 2025-12-29 15:26:25 +01:00
Author
Owner

@shift00 commented on GitHub (Dec 7, 2017):

When I want to create/edit my entity I receive this error:

[CoreStore: Fatal Error] BaseDataTransaction.swift:83 create
  ↪︎ Attempted to create an entity of type 'Entity1CSModel', but a destination persistent store containing the entity type could not be found.
@shift00 commented on GitHub (Dec 7, 2017): When I want to create/edit my entity I receive this error: ``` [CoreStore: Fatal Error] BaseDataTransaction.swift:83 create ↪︎ Attempted to create an entity of type 'Entity1CSModel', but a destination persistent store containing the entity type could not be found. ```
Author
Owner

@JohnEstropia commented on GitHub (Dec 7, 2017):

addStorage() is an asynchronous operation. Are you sure that your create() call is not being called before the addStorage() completes?

@JohnEstropia commented on GitHub (Dec 7, 2017): `addStorage()` is an asynchronous operation. Are you sure that your `create()` call is not being called before the `addStorage()` completes?
Author
Owner

@shift00 commented on GitHub (Dec 7, 2017):

@JohnEstropia I moved block of code when is executed after addStorage() into completion handler and it's working ;) Thanks for tip 👍

@shift00 commented on GitHub (Dec 7, 2017): @JohnEstropia I moved block of code when is executed after `addStorage()` into completion handler and it's working ;) Thanks for tip 👍
Author
Owner

@JohnEstropia commented on GitHub (Dec 7, 2017):

That's great to hear :)

@JohnEstropia commented on GitHub (Dec 7, 2017): That's great to hear :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#191