Sure, here's my header file:
@interface ExpensesListViewController : UITableViewController <SCTableViewModelDataSource, SCTableViewModelDelegate> {
SCTableViewModel *tableModel;
}
And this is my implementation
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
self.navigationItem.rightBarButtonItem = addButton;
[addButton release];
NSManagedObjectContext *managedObjectContext = [(SimpleExpensesAppDelegate *)[UIApplication sharedApplication].delegate managedObjectContext];
SCClassDefinition *expenseDef = [SCClassDefinition definitionWithEntityName:@"Expense" withManagedObjectContext:managedObjectContext
withPropertyNames:[NSArray arrayWithObjects:@"amount", @"desc", @"currency", nil]];
// Rename desc to description
SCPropertyDefinition *descPropertyDef = [expenseDef propertyDefinitionWithName:@"desc"];
descPropertyDef.title = @"Description";
// Currencies
SCPropertyDefinition *currencyPropertyDef = [expenseDef propertyDefinitionWithName:@"currency"];
currencyPropertyDef.type = SCPropertyTypeSelection;
currencyPropertyDef.attributes = [SCSelectionAttributes attributesWithItems:[NSArray arrayWithObjects:@"$", @"€", @"₤", @"¥", nil]
allowMultipleSelection:NO
allowNoSelection:NO
autoDismissDetailView:YES
hideDetailViewNavigationBar:NO];
tableModel = [[SCTableViewModel alloc] initWithTableView:self.tableView withViewController:self];
SCArrayOfObjectsSection *expensesSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withEntityClassDefinition:expenseDef];
expensesSection.addButtonItem = self.navigationItem.rightBarButtonItem;
[tableModel addSection:expensesSection];
}
- (void)dealloc {
[tableModel release];
[super dealloc];
}