user798719
user798719

Reputation: 9869

How to decouple NSFetchedResultsController from a UITableViewController?

I may be overthinking this here. But here is my overall architecture for my app:

NIB-->UITableViewController-->TweetsService-->TweetEntities (in core data)

My UITableViewController asks my TweetsService for all of the tweets, and the TweetsService gives back the array of Tweets to my UITableViewController, no questions asked. It is the TweetsService that talks to core data, and nothing else.

If I add in an NSFetchedResultsController, doesn't that make my UITableViewController bypass my TweetsService? Is this architecturally correct? Should I re-route NSFetchedResultsController to go through my TweetsService? I don't see how I'd do that, though. Or am I overthinking this?

Upvotes: 1

Views: 226

Answers (1)

Chris Wagner
Chris Wagner

Reputation: 21003

NSFetchedResultsController is effectively your data source, so rather than your UITableViewDataSource asking the NSArray your TweetsService vends for specific things (count, cellForIndex, etc...), it would ask the instance of NSFetchedResultsController these things. You could definitely make your TweetsService vend an NSFetchedResultsController

Upvotes: 1

Related Questions