Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SuperCoreStack should be 100% decoupled from NSFetchedResultsControllerExtension #25

Open
rromanchuk opened this issue Mar 16, 2015 · 3 comments

Comments

@rromanchuk
Copy link
Contributor

This extension is a great class, but it needs to be decoupled.
https://github.com/michaelarmstrong/SuperRecord/blob/master/SuperRecord/NSFetchedResultsControllerExtension.swift#L102

We use a more advanced stack so this line gives us problems. In general it's probably better to force the callee to be responsible for sending the MOC, always. In general calling back up to the delegate for the moc is bad practice, especially when there isn't just a single MOC being used everywhere.

@michaelarmstrong
Copy link
Owner

The callee CAN be responsible for sending the MOC, but if you don't it will default back to another. However, this pattern will change soon as i'm developing a new pattern for this area (see issue: #22 ).

In regards to calling back up to the delegate, would you prefer the receiver sets the delegate on a returned object from that method manually? If you could could write up a quick 10 line example of your suggestion it'd help.

@rromanchuk
Copy link
Contributor Author

@michaelarmstrong the problem is with the actual default, I don't include that class in my project. I actually like NSFetchedResultsControllerExtension setting up the binding, i just had to rip the the stack out of that class so it wouldn't crash. No one ever does this, but developers should be "data passing" their moc between controllers, this paradigm would align with forcing the user to explicitly make a decision about what moc the NSFRC will be listening too. On my project my fix was just removing the default

@rromanchuk
Copy link
Contributor Author

This is my usage

lazy var fetchedResultsController: NSFetchedResultsController = NSFetchedResultsController.superFetchedResultsController("Post", sectionNameKeyPath: nil, sortDescriptors: self.sortDescriptors, predicate: self.predicate, tableView: self.tableView, context: self.managedObjectContext)

rromanchuk added a commit to rromanchuk/SuperRecord that referenced this issue Aug 22, 2015
Setting this default forces a dependency on SuperCoreDataStack, it also encourages very bad practice via blase/naive management of
the context. The callee can still use this class, but should be forced to pass in the context. Related to michaelarmstrong#25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants