Originally created by @iby on GitHub (Aug 28, 2020).
Either I'm doing something stupid or got a really weird one… The following is performed on the main thread, tried with waitForAllObservers: false and asynchronous. It runs fine, other observers get notified of changes, all goes smoothly. As soon as I reload the app I see models showing old unmodified data.
Can you think of anything what might be causing this?
Originally created by @iby on GitHub (Aug 28, 2020).
Either I'm doing something stupid or got a really weird one… The following is performed on the main thread, tried with `waitForAllObservers: false` and asynchronous. It runs fine, other observers get notified of changes, all goes smoothly. As soon as I reload the app I see models showing old unmodified data.
```swift
try CoreStoreDefaults.dataStack.perform(synchronous: { transaction in
guard let model = transaction.edit(model) else { throw ModelError.cannotEdit }
Swift.print(">>>", "transaction.hasChanges: \(transaction.hasChanges), model.hasChanges: \(model.hasChanges), equal: \(model.exportURL == newExportURL)")
model.exportURL = newExportURL
Swift.print("<<<", "transaction.hasChanges: \(transaction.hasChanges), model.hasChanges: \(model.hasChanges), equal: \(model.exportURL == newExportURL)")
})
// >>> transaction.hasChanges: false, model.hasChanges: false, equal: false
// <<< transaction.hasChanges: false, model.hasChanges: true, equal: true
```
What's weird is that model reports changes after updating, but transaction isn't. The model object looks as follows:
```swift
public final class Model: NSManagedObject {
@NSManaged public var date: Date
@NSManaged public var documentURL: URL?
@NSManaged public var exportURL: URL
}
```
Can you think of anything what might be causing this?
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @iby on GitHub (Aug 28, 2020).
Either I'm doing something stupid or got a really weird one… The following is performed on the main thread, tried with
waitForAllObservers: falseand asynchronous. It runs fine, other observers get notified of changes, all goes smoothly. As soon as I reload the app I see models showing old unmodified data.What's weird is that model reports changes after updating, but transaction isn't. The model object looks as follows:
Can you think of anything what might be causing this?
@iby commented on GitHub (Aug 28, 2020):
Ah yes, I'm an epic moron. Never mind me… 🤦♂️
@gardyna commented on GitHub (Dec 10, 2020):
@ianbytchek thanks for the helpfull comment. can you please tell me what was wrong?
@iby commented on GitHub (Dec 10, 2020):
To be honest I don't remember, but I think I was editing a model that was not saved.