NimbusKit
1.2.1 - Fork Nimbus on Github - Visit the Nimbus Wiki
The iOS framework that grows only as fast as its documentation
|
The NIMutableCollectionViewModel class is a mutable collection view model.
When modifications are made to the model there are two ways to reflect the changes in the collection view.
The latter option is the recommended approach to adding new cells to a collection view. Each method in the mutable collection view model returns a data structure that can be used to inform the collection 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: |
Creating Collection View Cells | |
id< NICollectionViewModelDelegate > | delegate property |
Creating Collection 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. |
A delegate used to fetch collection view cells for the data source.
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.