NimbusKit
1.2.1 - Fork Nimbus on Github - Visit the Nimbus Wiki
The iOS framework that grows only as fast as its documentation
|
The NIMutableTableViewModel class is a mutable table view model.
When modifications are made to the model there are two ways to reflect the changes in the table view.
The latter option is the recommended approach to adding new cells to a table view. Each method in the mutable table view model returns a data structure that can be used to inform the table view of the exact modifications that have been made to the model.
Example of adding a new section:
Tasks | |
Modifying Objects | |
(NSArray *) | - addObject: |
(NSArray *) | - addObject:toSection: |
(NSArray *) | - addObjectsFromArray: |
(NSArray *) | - insertObject:atRow:inSection: |
(NSArray *) | - removeObjectAtIndexPath: |
Modifying Sections | |
(NSIndexSet *) | - addSectionWithTitle: |
(NSIndexSet *) | - insertSectionWithTitle:atIndex: |
(NSIndexSet *) | - removeSectionAtIndex: |
Updating the Section Index | |
(void) | - updateSectionIndex |
Configuration | |
NITableViewModelSectionIndex | sectionIndexType property |
BOOL | sectionIndexShowsSearch property |
BOOL | sectionIndexShowsSummary property |
(void) | - setSectionIndexType:showsSearch:showsSummary: |
Creating Table View Cells | |
NITableViewModelCellForIndexPathBlock | createCellBlock property |
Creating Table View Models | |
(id) | - initWithDelegate: |
(id) | - initWithListArray:delegate: |
(id) | - initWithSectionedArray:delegate: |
Accessing Objects | |
(id) | - objectAtIndexPath: |
(NSIndexPath *) | - indexPathForObject: |
Appends an object to the last section.
If no sections exist, a section will be created without a title and the object will be added to this new section.
object | The object to append to the last section. |
Appends an object to the end of the given section.
object | The object to append to the section. |
section | The index of the section to which this object should be appended. |
Appends an array of objects to the last section.
If no section exists, a section will be created without a title and the objects will be added to this new section.
array | The array of objects to append to the last section. |
Inserts an object into the given section at the given row.
object | The object to append to the section. |
row | The row within the section at which to insert the object. |
section | The index of the section in which the object should be inserted. |
Removes an object at the given index path.
If the index path does not represent a valid object then a debug assertion will fire and the method will return nil without removing any object.
indexPath | The index path at which to remove a single object. |
Appends a section with a given title to the model.
title | The title of the new section. |
Inserts a section with a given title to the model at the given index.
title | The title of the new section. |
index | The index in the model at which to add the new section. |
Removes a section at the given index.
index | The index in the model of the section to remove. |
Updates the section index with the current section index settings.
This method should be called after modifying the model if a section index is being used.
The section index type.
You will likely use NITableViewModelSectionIndexAlphabetical in practice.
NITableViewModelSectionIndexNone by default.
Whether or not the search symbol will be shown in the section index.
NO by default.
Whether or not the summary symbol will be shown in the section index.
NO by default.
A block used to create a UITableViewCell for a given object.
Initializes a newly allocated static model with the given delegate and empty contents.
This method can be used to create an empty model.
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.
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.
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.
Returns the index path of the given object within the model.
If the model does not contain the object then nil will be returned.
Configures the model's section index properties.
Calling this method will compile the section index depending on the index type chosen.
sectionIndexType | The type of section index to display. |
showsSearch | Whether or not to show the search icon at the top of the index. |
showsSummary | Whether or not to show the summary icon at the bottom of the index. |