magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.79k stars 1.79k forks source link

Using NSFetchedResultsController along with Magical Record? #404

Closed ralfr closed 11 years ago

ralfr commented 11 years ago

In scenarios, where one has to load potentially hundreds of records and (e.g.) display those in a UITableView, Apple suggests using the NSFetchedResultsController in order to lazy load at the time of display.

I'm unsure how a scenario like this would be implemented "correctly" alongside Magical Record? I understand, that Magical Record adds stuff on top of CoreData, so I could just use NSFetchedResultsController in parallel.

However, I'm wondering what would be the correct way of doing this? Is there anything in Magical Records, that sort of replaces NSFetchedResultsController?

berkus commented 11 years ago

You could use [NSManagedObject MR_fetchController:] and friends (there's about 15 methods total), see NSManagedObject+MagicalFinders.m

ralfr commented 11 years ago

Thanks, @berkus. I wonder whether there are any tutorials or any further documentation out there, explaining how to use those?

berkus commented 11 years ago

I tried it out, it works exactly the same way as you would with the NSFetchedResultsController. I'm still a bit confused as to how the groupedBy: and sortedBy: would work in case of multiple keys (haven't looked into the source yet), but the rest works fairly predictably. You simply get an NSFetchedResultsController in return and work with it as usual.

casademora commented 11 years ago

The NSFRC helpers in MagicalRecord aren't much more than simple wrappers around creation the fetch request, creating the NSFRC and launching the fetch. It was written when the NSFRC was frankly pretty bad…we'll be looking at adding more convenience methods now that it's finally stabilized and sorta works now :) Feel free to send in your ideas or pull requests!

Saul Mora saul@casademora.com (mailto:saul@casademora.com) http://about.me/saulmora

On Monday, February 4, 2013 at 10:23 PM, Berkus wrote:

I tried it out, it works exactly the same way as you would with the NSFetchedResultsController. I'm still a bit confused as to how the groupedBy: and sortedBy: would work in case of multiple keys (haven't looked into the source yet), but the rest works fairly predictably. You simply get an NSFetchedResultsController in return and work with it as usual.

— Reply to this email directly or view it on GitHub (https://github.com/magicalpanda/MagicalRecord/issues/404#issuecomment-13115173).

berkus commented 11 years ago

I'm so far happy with what MR provides, but we'll see!