Inherits from UITableViewController
Conforms to NSFetchedResultsControllerDelegate
Declared in SCDataTableViewController.h

Overview

SCDataTableViewController is an abstract base class for TableViews presenting C2Call SDK CoreData Elements.

This abstract base class currently supports the following CoreData Entities:

- MOC2CallUser
- MOC2CallEvent
- MOChatHistory
- MOCallHistory

The character of this UITableViewController subclass is abstract, as the developer needs to subclass this controller and has to overwrite the following methods:

fetchRequest:
configureCell:atIndexPath

The developer also must set the cellIdentifier with the identifier of his custom UITableViewCell.

Code Sample from WhazzUpp WUFavoritesViewController:

 #import <SocialCommunication/SocialCommunication.h>

 @interface WUFavoritesCell : UITableViewCell

 @property(nonatomic, weak) IBOutlet UILabel     *nameLabel, *statusLabel, *onlineLabel;

 @end

 @interface WUFavoritesViewController : SCDataTableViewController

 -(IBAction)toggleEditing:(id)sender;

 @end

 @implementation WUFavoritesViewController
 ...skip...
 - (void)viewDidLoad
 {
     [super viewDidLoad];
     self.cellIdentifier = @"WUFavoritesCell";

     UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:self.cellIdentifier];
     favoritesCellHeight = cell.frame.size.height;
 }

 -(NSFetchRequest *) fetchRequest
 {
    return [[SCDataManager instance] fetchRequestForFriendlist:YES];
 }

 -(void) configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
 {
    MOC2CallUser *user = [self.fetchedResultsController objectAtIndexPath:indexPath];

    if ([cell isKindOfClass:[WUFavoritesCell class]]) {
        WUFavoritesCell *favocell = (WUFavoritesCell *) cell;
        favocell.nameLabel.text = [[C2CallPhone currentPhone] nameForUserid:user.userid];
        favocell.statusLabel.text = @"Hi there, I'm using WhazzUpp!";
    }
 }
 ...skip...
@end

Properties

cellIdentifier

Sets the cellIdentifier for UITableView dequeueReusableCellWithIdentifier:

@property (nonatomic, strong) NSString *cellIdentifier

Declared In

SCDataTableViewController.h

fetchedResultsController

NSFetchedResultsController will be created automatically on ViewController initialization.

@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController

Declared In

SCDataTableViewController.h

sectionNameKeyPath

A key path on result objects that returns the section name. Pass nil to indicate that the controller should generate a single section. The section name is used to pre-compute the section information. If this key path is not the same as that specified by the first sort descriptor in fetchRequest, they must generate the same relative orderings. For example, the first sort descriptor in fetchRequest might specify the key for a persistent property; sectionNameKeyPath might specify a key for a transient property derived from the persistent property.

@property (nonatomic, strong) NSString *sectionNameKeyPath

Declared In

SCDataTableViewController.h

useDidChangeContentOnly

Don’t do row updates, just notify content changes

@property (nonatomic) BOOL useDidChangeContentOnly

Declared In

SCDataTableViewController.h

Instance Methods

configureCell:atIndexPath:

Configure your UITableViewCell subclass.

- (void)configureCell:(id)cell atIndexPath:(id)indexPath

Discussion

This abstract method must be overwritten in a SCDataTableViewController subclass.

SampleCode: -(void) configureCell:(UITableViewCell )cell atIndexPath:(NSIndexPath )indexPath { MOC2CallUser *user = [self.fetchedResultsController objectAtIndexPath:indexPath];

    if ([cell isKindOfClass:[WUFavoritesCell class]]) {
        WUFavoritesCell *favocell = (WUFavoritesCell *) cell;
        favocell.nameLabel.text = [[C2CallPhone currentPhone] nameForUserid:user.userid];
        favocell.statusLabel.text = @"Hi there, I'm using WhazzUpp!";
    }
 }

Depending on the fetchRequest the “[self.fetchedResultsController objectAtIndexPath:indexPath]” provides the following NSManagedObject subclasses:

- MOC2CallUser
- MOC2CallEvent
- MOChatHistory
- MOCallHistory

Declared In

SCDataTableViewController.h

fetchRequest

Abstract method fetchRequest.

This abstract method must be overwritten in a SCDataTableViewController subclass. Please return one of the pre-defined fetchRequest from SCDataManager here:

- fetchRequestForChatHistory
- fetchRequestForCallHistory
- fetchRequestForEventHistory
- fetchRequestForFriendlist
- (NSFetchRequest *)fetchRequest

Return Value

The fetchRequest

Declared In

SCDataTableViewController.h

initFetchedResultsController

NSFetchedResultsController Initialization

- (void)initFetchedResultsController

Declared In

SCDataTableViewController.h