0

I've got a view controller with a tablview that shows data from an NSFetchedResultsController and that's great, it's working well.

Each object in the FRC represents a file which has or hasn't yet been downloaded from the server. When the user taps on a row, the app checks if the file has been downloaded, and if not downloads it, and then updates the object to flag that it has been downloaded. When the user taps the row again, it should know it's been downloaded, and simply open the file.

What's happening however, is that the file is downloaded, and the object is being updated, however when I tap on the row again, it the FRC's version of the object hasn't been updated to reflect the new changes, so it doesn't think that the file has been downloaded and thus downloads it again.

Do I need to re-fetch the data in the FRC or am I doing something else wrong? Thanks

PaReeOhNos
  • 4,338
  • 3
  • 30
  • 41
  • Do you update the objects in a background thread? Then this question and the workaround might help: http://stackoverflow.com/questions/14018068/nsfetchedresultscontroller-doesnt-call-controllerdidchangecontent-after-update. – Martin R Dec 29 '12 at 18:04
  • All changes are performed in the same background thread, using [context performBlock:] or [context performBlockAndWait:] – PaReeOhNos Dec 29 '12 at 18:05
  • But the FRC is working on the main thread? Do you use a nested child context for the background MOC? – Martin R Dec 29 '12 at 18:11
  • I do yeah. I found the issue though. It wasn't a threading thing (although I do need to check things like that). I had made a mistake somewhere else which was creating random objects that weren't related, so my FRC was returning the wrong objects and when the other objects were updated, the FRC wasn't updating as it didn't know about them :( – PaReeOhNos Dec 29 '12 at 18:13

1 Answers1

0

Turns out it was my own mistake. I had an issue somewhere else that was causing new objects to be created so the FRC was returning the wrong objects. Then when the correct objects were being updated, the FRC didn't know about it as it had references to the wrong ones

PaReeOhNos
  • 4,338
  • 3
  • 30
  • 41