Hi Martin:
Let me answer number two first, as it will aid in number one's answer.
2- Sensible TableView does not at all disable sorting. On the contrary, it gives you two sorting options:
a.
Automatic sorting. If you create an SCArrayOfObjectsSection with the sectionWithHeaderTitle:withEntityClassDefinition:, STV will automatically sort all the objects with the entity defined in the SCClassDefinition, according to the SCClassDefinition "key" property. By default, the class definition's key property has the same value as the first attribute in the entity. For an example of this, please refer to the Core Data App sample application.
b.
Manual Sorting. This method gives you the maximum flexibility, not just with sorting, but also with selecting any subset of the objects you have in your Core Data graph. With this option, you should usually create an SCArrayOfObjectsSection using the sectionWithHeaderTitle:withItems:withClassDefinition: method. Here is code sample that illustrates that:
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:myEntity];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
initWithKey:@"sortKey" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
NSMutableArray *sectionItems = [NSMutableArray arrayWithArray:[self.managedObjectContext executeFetchRequest:fetchRequest error:NULL]];
[sortDescriptor release];
[sortDescriptors release];
[fetchRequest release];
SCArrayOfObjectsSection *objectsSection =
[SCArrayOfObjectsSection sectionWithHeaderTitle:nil withItems:sectionItems
withClassDefinition:myClassDefinition];
Now for question number 1:
1- I am assuming you now have an automatically generated detail view with all the group attributes, and all you need is add an extra section with the persons associated with this group. If I understand you correctly, I think all you need to do is add a new SCArrayOfObjectsSection to the automatically generated view, using very similar code to the code above. You can have access to all automatically generated detail view model's using the SCTableViewModelDelegate method: tableViewModel:detailViewWillAppearForSectionAtIndex:withDetailTableViewModel:
Here is some sample code to illustrate this:
- (void)tableViewModel:(SCTableViewModel *)tableViewModel
detailViewWillAppearForSectionAtIndex:(NSUInteger)index withDetailTableViewModel:
(SCTableViewModel *)detailTableViewModel
{
NSFetchRequest *myFetchRequest = ... // Create your customized fetch request here
NSMutableArray *sectionItems = [NSMutableArray arrayWithArray:
[self.managedObjectContext executeFetchRequest:myFetchRequest error:NULL]];
[myFetchRequest release];
SCArrayOfObjectsSection *objectsSection =
[SCArrayOfObjectsSection sectionWithHeaderTitle:nil withItems:sectionItems
withClassDefinition:myClassDefinition];
[detailTableViewModel addSection:objectsSection];
}
Hope this helps