Comments (9)
Can you tell us which version of this library you're using?
Because we're using an unowned
reference to self
in the saveContext
method, and that method executes asynchronously, it's possible for the NSManagedObjectContext
instance to be deallocated by ARC before the async save block executes. If you're doing background work on another thread/queue that calls saveContext
and finishes its work before that block is done, this could result.
While we could use weak
and prevent the crash, it may make the code in saveContext
a no-op, which is probably not what you would expect.
We'll look at making the memory semantics of this more clear, but the better fix is probably to use saveContextAndWait
for background operations in your code instead.
from coredatastack.
It might be more in keeping with the intent of a save
call to drop both unowned
and weak
and instead hold a strong reference to the object till the save completes. I think this would take only a two-word change: remove the [unowned self]
in saveContext
from SaveHelpers.swift:51.
from coredatastack.
@jeremy-w I like this idea. 👍 I'll let @lyricsboy take a look today and see if we can put a unit test together to cover this case before proceeding.
from coredatastack.
Can I help with it?
from coredatastack.
@bitomule: Sure, the unowned -> strong switch outlined above will hopefully fix it. If you could apply that and verify that it stops your app from crashing, that would be awesome. :D
BTW, did the crash happen reliably for you, or was it only sometimes crashing?
I think @rcedwards was hoping to put a test over it, but that will be hard without introducing something like "build test-only project, run the executable from the test, wait for it to exit, fail if it didn't exit cleanly", since a failing test within the test process will kill the test process itself and prevent running other tests. :)
from coredatastack.
@jeremy-w that could fix it but my issue only happened once after a lot's of saves so not easy way to test it.
from coredatastack.
Addressed in https://github.com/bignerdranch/CoreDataStack/releases/tag/v1.0.2
from coredatastack.
Thanks, will report if it occurs again. Btw, today we released our iOS app with a powerful core data stack 👍
from coredatastack.
@bitomule fantastic news 🎉 We're happy our stack was able to help with your project.
from coredatastack.
Related Issues (20)
- Can't run app in simulator with BNRCoreDataStack in Objective-C project, LaunchServicesError HOT 1
- Build issues with Xcode 8 beta 3 HOT 4
- Creating CoreDataStack without dispatching HOT 2
- When using Mogenerator, making a ManagedObject implement CoreDataModelable gives error HOT 6
- NSPersistentStoreCoordinator options. HOT 5
- (Swift 3) Make `performAndWaitOrThrow` `rethrows` and `@noescape` HOT 1
- Issue compiling project with BNRCoreDataStack using Xcode 8 - Swift 2.3 HOT 1
- Publish Pod version 2.0.0 HOT 1
- performAndWaitOrThrow not accessible HOT 5
- Linker issue HOT 2
- Linker issue HOT 5
- Entity name check should not fail because of module name HOT 5
- BNRCOredatastack 1.3.0 issue in xcode 8.2 unable to install on device
- Question: is `.findFirstInContext(...)` not available any more on iOS < 10? HOT 3
- Support programatically created object models HOT 2
- Carthage validation script fails for forks
- Use withoutActuallyEscaping for helpers on Swift 3.1 HOT 5
- How can i use CoreDataStack in an Objective-C project HOT 1
- Xcode 9 support HOT 1
- crash on update of app from app store HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coredatastack.