Update: This post will provides an overview of my problem, but Edit of post #5 by me explains the specific issue I'm having right now.
I have three interrelated entities in a core data model: Correspondents, Subjects, and Messages.
Each and every message has exactly one subject, but each subject may have multiple messages.
Messages may have any number of correspondents and correspondents may have any number of messages.
Subjects may have any number of correspondents and correspondents may have any number of subjects.
I'm starting from the Master-Detail with Core Data template in Xcode. I'd like to make it so that it displays a list of all of the Correspondents with unique Subjects (that is, the Subject has no other Correspondents) as well as all of the Subjects that are shared between Correspondents. I'd like to then sort them all together by their most recent Message (they're all timestamped.)
The issue is that as far as I can tell, a fetchedResultsController should only have a single fetch entity type.
Two possible solutions come to mind:
1 - Make a single superentity that both Correspondents and Subjects inherit from. I can't think of any technical reason why not, but something about it sounds hacky. Or maybe it's just how many headaches I feel like Core Data induces...
2 - Make two fetchedResultsControllers and use both... but then how am I going to manage sorting? Also, something about having two controller classes for a single table view doesn't sound right... it sounds hacky just like #1.
I'm already able to list all of the messages and using the debugger to inspect them suggests that the relationships are being created the way I want them to be.
Which way would people here suggest going about this - is there perhaps another way that someone else has to suggest?
I have three interrelated entities in a core data model: Correspondents, Subjects, and Messages.
Each and every message has exactly one subject, but each subject may have multiple messages.
Messages may have any number of correspondents and correspondents may have any number of messages.
Subjects may have any number of correspondents and correspondents may have any number of subjects.
I'm starting from the Master-Detail with Core Data template in Xcode. I'd like to make it so that it displays a list of all of the Correspondents with unique Subjects (that is, the Subject has no other Correspondents) as well as all of the Subjects that are shared between Correspondents. I'd like to then sort them all together by their most recent Message (they're all timestamped.)
The issue is that as far as I can tell, a fetchedResultsController should only have a single fetch entity type.
Two possible solutions come to mind:
1 - Make a single superentity that both Correspondents and Subjects inherit from. I can't think of any technical reason why not, but something about it sounds hacky. Or maybe it's just how many headaches I feel like Core Data induces...
2 - Make two fetchedResultsControllers and use both... but then how am I going to manage sorting? Also, something about having two controller classes for a single table view doesn't sound right... it sounds hacky just like #1.
I'm already able to list all of the messages and using the debugger to inspect them suggests that the relationships are being created the way I want them to be.
Which way would people here suggest going about this - is there perhaps another way that someone else has to suggest?
Last edited: