Skip to content
This repository has been archived by the owner on Jun 2, 2018. It is now read-only.

Type safe fetched results controller #55

Merged
merged 28 commits into from
Dec 1, 2015

Conversation

rcedwards
Copy link
Contributor

  • Added a type safe Fetched Results Controller thanks to @jgallagher and @zwaldowski
  • Updated the sample project with an example
  • Wrote unit test cases around the FRC
  • Updated the docs with better Markdown sugar

This helps illustrate the view controllers being swapped out
when the stack is finished being constructed.
John G. had discovered the documented compiler issue observed when switching on the enum

Compiler emits "PHI node operands are not the same type as the result!"
Previously all 100 books were being inserted here.
That has been moved to the setup func so instead we'll
just insert a single new book.
sectionNameKeyPath: "firstInitial")
let frcDelegate = BooksFetchedResultsControllerDelegate(tableView: self.tableView)
frc.setDelegate(frcDelegate)
return frc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FRC delegate should be weak, so shouldn't the frcDelegate be owned strongly somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. Updated.

This initializer takes a custom sort predicate however it was not being used at this time.

This use of sort (and related ones) is problematic, as it might cause I/O to fetch all the objects in a section — Core Data arrays are lazy.
…r a given change

An insert should have a newIndexPath, a delete should have an older indexPath etc.

This way NSIndexPath? instances aren't being forcibly unwrapped.
@rcedwards
Copy link
Contributor Author

I believe I've addressed everything if someone else wants to give a quick run through.

Work around a bug in Xcode 7.0 and 7.1 when running on iOS 8 - updated objects
sometimes result in both an Update *and* and Insert call to didChangeObject, which
makes no sense. Thankfully the bad Inserts have a non-nil "old" indexPath (which
also makes no sense) - we check for that here and ignore those erroneous messages.

For more discussion, see https://forums.developer.apple.com/thread/12184
@rcedwards
Copy link
Contributor Author

@zwaldowski gotcha. Updated

@zwaldowski
Copy link
Contributor

👍 We're well on our way to a great next release!

zwaldowski added a commit that referenced this pull request Dec 1, 2015
…ntroller

Type safe fetched results controller
@zwaldowski zwaldowski merged commit 80a867c into master Dec 1, 2015
@zwaldowski zwaldowski deleted the rcedwards/fetched_results_controller branch December 1, 2015 21:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants