Recently, I develop an application with Core Data. Considering about the concurrency with Core Data, I use the parent/child MOC pattern that is basic to this great article.
However, there is still a question --- Does the child MOC need to be cleaned manually after saving? i.e. childContext = nil;
There are less documentation about the parent/child MOC pattern.
Could somebody give me a hand? Thanks a lot.
Yes, the child context should be deleted as soon as you are finished working with it.
If you have a strong/retain @property
pointing to the child context, you should set it to nil once you don't need it anymore.
If you don't have any strong/retain properties then ARC will insert a line of code to deallocate the child context immediately after your last line of code that uses childContext.
If ARC is disabled, it should be autoreleased when the app is next idle.
So basically, you should not need to manually remove it. But there are some situations where you do have to manually do so. You won't find any managed object specific documentation about this, it's standard memory management in objective-c and would only be documented if it behaved differently.