15

Screenshot

If you look at Matt Gallagher's Cocoa With Love blog, he has a brilliant discussion (with sample code) on a fresh a beautiful retake on UITableView ... In the post, he talks about it's great many benefits of animations and heterogeneous cells, etc. However, one of the limitations he lists is a bit of a show-stopper for me. It won't work with NSFetchedResultsController. The design of loading data into the cells assumes that all that data is static and available immediately. However, if you are building a table with many rows and your data consists of objects in Core Data, your view controller would likely benefit greatly if you had access to the cacheing and dynamic loading capability of FRC.

My question: Has anyone put any effort into re-tasking his revisited UITableView design for use with NSFetchedResultsController? If someone's already done it (or is working on it), I would love (LOVE) to try it in my work or even help develop it.

Community
  • 1
  • 1
Greg Combs
  • 4,252
  • 3
  • 33
  • 47
  • +1 for a good question. Not sure exactly what all you need, but if you are looking for lazy loading/caching for cells you could look into EGOImageLoading by the folks over at Enormego. Github is here https://github.com/enormego/EGOImageLoading – Jesse Naugher Jul 15 '11 at 22:57
  • Well, let me explain a little more. Each of my cells are actually backed by a core data object. Actually there's lots and lots of core data objects (think of them as database records for people, or maps, or calendar events .... actually, I have all of those things in core data, each represented by a cell in a table somewhere in my application). The only reason why I use core data is because it takes care of managing those large bits of data, searching through it, loading only what it needs to save memory. FRC is the glue between the table view cell and the data to load. – Greg Combs Jul 17 '11 at 04:58
  • So back to your response @jesse ... I like EGOImageLoading, but I'm not really worried about images ... it's the data behind the rest of the information in the cell. – Greg Combs Jul 17 '11 at 05:00
  • 2
    maybe I'm missing something important but isn't it very simply by following the MVC guidelines? You would have a data object from CoreData and a view object (in this case the one from cocoawithlove). On data change you call the `FetchedResultsController`-Delegate and update the view-object with the values stored in the data-object. –  Jul 18 '11 at 18:40
  • 2
    Could you please elaborate on exactly what it is you want to keep from Gallagher's approach? It seems to me that what distinguishes it from the standard approach is that it treats data as static. (Incidentally if you have access to iOS5 betas and WWDC2011 videos, have a look; there's been a lot added to UITableView.) – hatfinch Jul 19 '11 at 09:15

1 Answers1

7

Good to go... Changed Table Revisited, To support the Core Data Download.

Zoe
  • 27,060
  • 21
  • 118
  • 148
k-thorat
  • 4,873
  • 1
  • 27
  • 36
  • This looks pretty good. I had a bit of a crasher when running it but it was an easy fix. Certainly better than the alternative. – Greg Combs Jul 21 '11 at 21:28
  • I think it was just an error check issue, I've forgotten but I'll look into it again. I was running under Xcode 3.2 though. – Greg Combs Jul 23 '11 at 00:08
  • Maybe @phix23 is holding out for something more substantial? Dunno. I thought it awarded automatically once someone checked the answer. – Greg Combs Jul 23 '11 at 06:22
  • I don't like this solution for the following reasons: the code is not very reusable, the core data model is tied to the table view model - doesn't work for more complex data models or complex PageCells, it does not perform data fetches asynchronously, it does not implement NSFetchedResultsControllerDelegate and thus no updating of cells, it crashes when I click on a 'nib loaded cell'. I thought of a more reusable solution that is independant from the used core data model. – Felix Jul 24 '11 at 11:38
  • The bounty will be awarded automatically after 3 hours if @phix23 doesn't do it. – Sagar Jul 25 '11 at 06:52
  • 1
    @phix23 you should have expressed your thoughts when you started the bounty or 5 days back when I posted the answer instead of last moment, I would have tried something. – k-thorat Jul 25 '11 at 18:33
  • @TheAstra, do you have any interest in cooking up a modification that addresses some of phix23's issues? – Greg Combs Aug 03 '11 at 17:18
  • The link is dead - megaupload is gone. – Joe Nov 15 '13 at 05:06