Click here to support Nimbus development and make a donation at www.pledgie.com !
An iOS framework whose growth is bounded by O(documentation).
NITableViewModel Class Reference

Overview

A non-mutable table view model that complies to the UITableViewDataSource protocol.

This model allows you to easily create a data source for a UITableView without having to implement the UITableViewDataSource methods in your UITableViewController.

This base class is non-mutable, much like an NSArray. You must initialize this model with the contents when you create it.

Examples:

ExampleStaticTableModel.m.

Definition at line 379 of file NIFormCellCatalog.m.

Methods

Configuration
NITableViewModelSectionIndex sectionIndexType property
BOOL sectionIndexShowsSearch property
BOOL sectionIndexShowsSummary property
(void) - setSectionIndexType:showsSearch:showsSummary:
Creating Table View Cells
id< NITableViewModelDelegatedelegate property
NITableViewModelCellForIndexPathBlock createCellBlock property
Creating Table View Models
(id) - initWithDelegate:
(id) - initWithListArray:delegate:
(id) - initWithSectionedArray:delegate:
Accessing Objects
(id) - objectAtIndexPath:

Method Documentation

- NITableViewModel: [read, assign]

The section index type.

You will likely use NITableViewModelSectionIndexAlphabetical in practice.

NITableViewModelSectionIndexNone by default.

Definition at line 68 of file NITableViewModel.h.

- NITableViewModel: [read, assign]

Whether or not the search symbol will be shown in the section index.

NO by default.

Definition at line 69 of file NITableViewModel.h.

- NITableViewModel: [read, assign]

Whether or not the summary symbol will be shown in the section index.

NO by default.

Definition at line 70 of file NITableViewModel.h.

- NITableViewModel: [read, write, assign]

A delegate used to fetch table view cells for the data source.

Definition at line 74 of file NITableViewModel.h.

- NITableViewModel: [read, write, copy]

A block used to create a UITableViewCell for a given object.

Definition at line 79 of file NITableViewModel.h.

- (id) initWithDelegate: (id<NITableViewModelDelegate>)  delegate

Initializes a newly allocated static model with the given delegate and empty contents.

This method can be used to create an empty model.

Definition at line 56 of file NITableViewModel.m.

- (id) initWithListArray: (NSArray *)  sectionedArray
delegate: (id<NITableViewModelDelegate>)  delegate 

Initializes a newly allocated static model with the contents of a list array.

A list array is a one-dimensional array that defines a flat list of rows. There will be no sectioning of contents in any way.

Example

 NSArray* contents =
 [NSArray arrayWithObjects:
  [NSDictionary dictionaryWithObject:@"Row 1" forKey:@"title"],
  [NSDictionary dictionaryWithObject:@"Row 2" forKey:@"title"],
  [NSDictionary dictionaryWithObject:@"Row 3" forKey:@"title"],
  nil];
 [[NIStaticTableViewModel alloc] initWithListArray:contents delegate:self];

Definition at line 71 of file NITableViewModel.m.

- (id) initWithSectionedArray: (NSArray *)  sectionedArray
delegate: (id<NITableViewModelDelegate>)  delegate 

Initializes a newly allocated static model with the contents of a sectioned array.

A sectioned array is a one-dimensional array that defines a list of sections and each section's contents. Each NSString begins a new section and any other object defines a row for the current section.

Example

 NSArray* contents =
 [NSArray arrayWithObjects:
  @"Section 1",
  [NSDictionary dictionaryWithObject:@"Row 1" forKey:@"title"],
  [NSDictionary dictionaryWithObject:@"Row 2" forKey:@"title"],
  @"Section 2",
  // This section is empty.
  @"Section 3",
  [NSDictionary dictionaryWithObject:@"Row 3" forKey:@"title"],
  [NITableViewModelFooter footerWithTitle:@"Footer"],
  nil];
 [[NIStaticTableViewModel alloc] initWithSectionedArray:contents delegate:self];

Definition at line 80 of file NITableViewModel.m.

- (id) objectAtIndexPath: (NSIndexPath *)  indexPath

Returns the object at the given index path.

If no object exists at the given index path (an invalid index path, for example) then nil will be returned.

Definition at line 375 of file NITableViewModel.m.

- (void) setSectionIndexType: (NITableViewModelSectionIndex)  sectionIndexType
showsSearch: (BOOL)  showsSearch
showsSummary: (BOOL)  showsSummary 

Configures the model's section index properties.

Calling this method will compile the section index depending on the index type chosen.

Parameters:
sectionIndexTypeThe type of section index to display.
showsSearchWhether or not to show the search icon at the top of the index.
showsSummaryWhether or not to show the summary icon at the bottom of the index.

Definition at line 400 of file NITableViewModel.m.

Generated for Nimbus by doxygen 1.7.4-20110629