mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
How to link a Datastack to a monitor sectioned list. #107
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Dec 1, 2016).
At first, I linked
CoreStoreto a monitored sectioned list the same way that the sample code did it. That worked perfectly. However, I' am now trying to link aDataStackto a monitor sectioned list and nothing is happening. Here is the code for the dataStack.class ViewController: UIViewController, ListSectionObserver {
}
The "made it here" do not triggered, however when I simply link/use CoreStore and not make my own dataStack, they do get triggered.
@JohnEstropia commented on GitHub (Dec 2, 2016):
Hi, I think the problem is because you are assigning
to a local function variable. So once
viewDidLoad()exits, yourListMonitorgets deallocated.Try to retain the monitor with a property and see how it goes.
@ghost commented on GitHub (Dec 3, 2016):
Hi John, I tried that. Unfortunately, it always crashes at this line
switch context.parentStack!.persistentStoreForEntityClass(
entityClass,
configuration: nil,
inferStoreIfPossible: true
) {
With the message , unexpectedly found nil while unwrapping an Optional value. So parent Context must be nil. I'am not too sure how to fix that!
@ghost commented on GitHub (Dec 3, 2016):
I even changed the code to just save with a datastack instead of using the default core store and I still get the same crash. I only have one attribute in the entity message of type string, no relationships or anything (if that even matters)
class ViewController: UIViewController {
@ghost commented on GitHub (Dec 3, 2016):
when I put it as a static let in a private struct as in the example, it finally worked
@JohnEstropia commented on GitHub (Dec 6, 2016):
@rslim087g Sorry for the late reply. If making it
staticfixes it for you, then yourdataStackwas getting deallocated early. I'm not sure how your view controller is being used here, but you should make sure thatdataStacklives for longer than you need to use theListMonitor.(It's perfectly fine to keep it in a
staticas you did though)I'm closing this issue but feel free to ask anything else :)