SCTableViewModel Class Reference
Inherits from | NSObject |
Conforms to | SCInputAccessoryViewDelegate UIScrollViewDelegate UITableViewDataSource UITableViewDelegate |
Declared in | SCTableViewModel.h |
Overview
This class is the master mind behind all of Sensible TableView’s functionality.
Sensible TableView provides an alternative easy way to create sophisticated table views very quickly. The sophistication of these table views can range from simple text cells, to cells with controls, to custom cells that get automatically generated from your own classes. SCTableViewModel also automatically generates detail views for common tasks such as selecting cell values or creating new objects. Using SCTableViewModel, you can easily create full functioning applications in a matter of minutes.
SCTableViewModel is designed to be loosely coupled with your user interface elements. What this means is that you can use SCTableViewModel with Apple’s default UITableView or with any of your custom UITableView subclasses. Similarly, you can use SCTableViewModel with any UIViewController, or any of its subclasses, including UITableViewController or your own subclasses.
Architecture:
An SCTableViewModel defines a table view model with several sections, each section being of type SCTableViewSection. Each SCTableViewSection can contain several cells, each cell being of type SCTableViewCell.
Tasks
Creation and Initialization
-
+ modelWithTableView:
Allocates and returns an initialized SCTableViewModel bound to a UITableView.
-
– initWithTableView:
Returns an initialized ‘SCTableViewModel’ bound to a UITableView.
Configuration
-
enablePullToRefresh
Set to TRUE to enable pull-to-refresh functionality on the table view. Default: FALSE.
property -
pullToRefreshView
Contains a valid SCPullToRefreshView that automatically provides pull-to-refresh functionality to the table view.
property -
editButtonItem
When set to a valid UIBarButtonItem, SCTableViewModel automatically puts its table view in edit mode when the button is tapped. Note: Must be set if the model is to automatically show/hide editing mode sections.
property -
autoResizeForKeyboard
If TRUE, SCTableViewModel will automatically resize its tableView when the keyboard appears. Property defualts to FALSE if viewController is a UITableViewController subclass, as UITableViewController will automatically handle the resizing. Otherwise, it defaults to TRUE.
property -
sectionIndexTitles
An array of strings that serve as the title of sections in the tableView and appear in the index list on the right side of the tableView. tableView must be in plain style for the index to appear.
property -
autoGenerateSectionIndexTitles
If TRUE, SCTableViewModel will automatically generate the sectionIndexTitles array from the first letter of each section’s header title. Default: FALSE.
property -
autoSortSections
If TRUE, SCTableViewModel will automatically sort its sections alphabetically according to their header title value. To provide custom section sorting, implement the tableViewModel:sortSections: SCTableViewDataSource method instead. Default: FALSE.
property -
hideSectionHeaderTitles
If TRUE, all section header titles will be hidden. Default: FALSE.
property -
lockCellSelection
If TRUE, SCTableViewModel will prevent any cell from being selected. Default: FALSE.
property -
tag
An integer that you can use to identify different table view models in your application. Any detail model automatically gets its tag set to be the value of its parent model’s tag plus one. Default: 0.
property -
detailViewController
When set to a valid view controller, the model will use this controller to display all of its automatically generated detail views. This property is typically set in iPad applications where the model and its detailViewController co-exist in a UISplitViewController.
property -
autoAssignDataSourceForDetailModels
When TRUE, the model automatically assigns the dataSource of all detail models to the same value of its own data source. This option should be used carefully as setting it to TRUE will trigger all implemented dataSource methods for all detail models in the heirarchy. Default: FALSE.
property -
autoAssignDelegateForDetailModels
When TRUE, the model automatically assigns the delegate of all detail models to the same value of its own delegate. This option should be used carefully as setting it to TRUE will trigger all implemented delegate methods for all detail models in the heirarchy. Default: FALSE.
property -
modelActions
The set of model action blocks.
property -
sectionActions
The set of section action blocks that get applied to all the model’s sections.
property -
cellActions
The set of cell action blocks that get applied to all the model’s cells.
property -
theme
The theme used to style the model’s views. Default: nil.
property
Managing Sections
-
sectionCount
The number of sections in the model.
property -
– addSection:
Adds a new section to the model.
-
– insertSection:atIndex:
Inserts a new section at the specified index.
-
– sectionAtIndex:
Returns the section at the specified index.
-
– sectionWithHeaderTitle:
Returns the first section with the specified header title.
-
– indexForSection:
Returns the index of the specified section.
-
– removeSectionAtIndex:
Removes the section at the specified index from the model.
-
– removeAllSections
Removes all sections from the model.
-
– generateSectionsForObject:withDefinition:
Generates sections using the given object and its data definition. The method fully utilizes the definition’s groups feature by generating a section for each group.
-
– generateSectionsForObject:withDefinition:newObject:
Generates sections using the given object and its data definition. The method fully utilizes the definition’s groups feature by generating a section for each group.
-
– generateSectionsForObject:withDataStore:
Generates sections using the given object and its data store.
-
– generateSectionsForObject:withDataStore:newObject:
Generates sections using the given object and its data store.
-
– generateSectionsForUserDefaultsDefinition:
Generates sections using a user defaults definition.
Managing Cells
-
activeCell
The current active cell. A cell becomes active if it is selected or if its value changes.
property -
activeCellIndexPath
The indexPath of activeCell.
property -
activeCellControl
The current active input control.
property -
– cellAtIndexPath:
Returns the cell at the specified indexPath.
-
– indexPathForCell:
Returns the index path for the specified cell.
-
– indexPathForCellAfterCellAtIndexPath:rewind:
Returns the indexPath of the cell that comes after the specified cell in the model.
-
– indexPathForCellAfterCell:rewind:
Returns the indexPath of the cell that comes after the specified cell in the model.
-
– cellAfterCell:rewind:
Returns the cell that comes after the specified cell in the model.
-
– indexPathForCellBeforeCellAtIndexPath:rewind:
Returns the indexPath of the cell that comes before the specified cell in the model.
-
– indexPathForCellBeforeCell:rewind:
Returns the indexPath of the cell that comes before the specified cell in the model.
-
– cellBeforeCell:rewind:
Returns the cell that comes before the specified cell in the model.
-
– moveToNextCellControl:
Moves the first responder to the next cell control, automatically scrolling the table view as needed. If rewind is TRUE, the first responder is moved to the very first cell after the last cell has been reached.
-
– moveToPreviousCellControl:
Moves the first responder to the previous cell control, automatically scrolling the table view as needed. If rewind is TRUE, the first responder is moved to the very last cell after the first cell has been reached.
Managing Detail Views
-
– dismissAllDetailViewsWithCommit:
Dismisses all detail views, commiting all changes when commit is TRUE, otherwise it will ignore all changes.
Managing Model Values
-
valuesAreValid
TRUE if all the model’s section and cell values are valid.
property -
needsCommit
propertyThis property is TRUE if any of the model's cells or sections needs to be commited, otherwise it's FALSE.
-
commitButton
‘SCTableViewModel’ will automatically enable/disable the commitButton based on the valuesAreValid property, where commitButton is enabled if valuesAreValid is TRUE.
property -
– commitChanges
Forces the commit of all section and cell values into their respective bound objects. There is usually no need to call this method manually as it’s typically called by the framework when the user is ready to commit changes.
-
– reloadBoundValues
Reload’s the model’s bound values in case the associated bound objects or keys valuea has changed by means other than the cells themselves (e.g. external custom code).
Managing the Data Source and Delegate
-
dataSource
The object that acts as the data source of ‘SCTableViewModel’. The object must adopt the SCTableViewModelDataSource protocol.
property -
delegate
The object that acts as the delegate of ‘SCTableViewModel’. The object must adopt the SCTableViewModelDelegate protocol.
property
Miscellaneous
-
tableView
propertyThe UITableView bound to 'SCTableViewModel'.
-
modeledTableView
The UITableView bound to ‘SCTableViewModel’.
property -
viewController
propertyThe UIViewController of tableView.
-
inputAccessoryView
The keyboard input accessory view responsible for providing keyboard navigation between the different responders. Set to nil to disable the accessory view functionality.
property -
– clear
Clears all contents of the model.
-
– setTableViewEditing:animated:
Sets the editing mode for tableView.
-
– setModeledTableViewEditing:animated:
Sets the editing mode for tableView.
Internal Properties & Methods (should only be used by the framework or when subclassing)
-
live
Returns true if the modeled table view is live and displaying cells.
property -
swipeToDeleteActive
Property is used internally by the framework to determine if the table view is in swipe-to-delete editing mode.
property -
masterModel
Property is used internally by the framework to set the master model in a master-detail relationship.
property -
activeDetailModel
Holds the currently active detail model.
property -
– setActiveCell:
Warning: Method must only be called internally by the framework.
-
– setActiveCellControl:
Warning: Method must only be called internally by the framework.
-
– enterLoadingMode
Warning: Method must only be called internally by the framework.
-
– exitLoadingMode
Warning: Method must only be called internally by the framework.
-
– clearLastReturnedCellData
Warning: Method must only be called internally by the framework.
-
– configureDetailModel:
Warning: Method must only be called internally by the framework.
-
– keyboardWillShow:
Warning: Method must only be called internally by the framework.
-
– keyboardWillHide:
Warning: Method must only be called internally by the framework.
-
– valueChangedForSectionAtIndex:
Method gets called internally whenever the value of a section changes. This method should only be used when subclassing ‘SCTableViewModel’. If what you want is to get notified when a section value changes, consider using SCTableViewModelDelegate methods.
-
– valueChangedForRowAtIndexPath:
Method gets called internally whenever the value of a cell changes. This method should only be used when subclassing ‘SCTableViewModel’. If what you want is to get notified when a cell value changes, consider using either SCTableViewModelDelegate or the cell’s actions.
-
– setTargetForModelModifiedEvent:action:
Method used internally by the framework to monitor model modification events.
-
– didTapEditButtonItem
Subclasses should override this method to handle when editButtonItem is tapped.
-
– pullToRefreshViewDidStartLoading
Method called by pullToRefreshView to initiate refresh.
-
– styleSections
Method called internally.
-
– styleViews
Method called internally.
-
– styleCell:atIndexPath:onlyStylePropertyNamesInSet:
Method called internally.
-
– configureCell:atIndexPath:
Method called internally.
-
– styleCell:atIndexPath:
Method called internally.
iCloud Methods
-
– generateSectionsForiCloudKeyValueDefinition:
Generates table view sections using an iCloud key-value definition.
Properties
activeCell
The current active cell. A cell becomes active if it is selected or if its value changes.
@property (nonatomic, readonly) SCTableViewCell *activeCell
Declared In
SCTableViewModel.h
activeCellControl
The current active input control.
@property (nonatomic, readonly) UIResponder *activeCellControl
Declared In
SCTableViewModel.h
activeCellIndexPath
The indexPath of activeCell.
@property (nonatomic, readonly) NSIndexPath *activeCellIndexPath
Declared In
SCTableViewModel.h
activeDetailModel
Holds the currently active detail model.
@property (nonatomic, unsafe_unretained) SCTableViewModel *activeDetailModel
Discussion
Warning: Property must only be set internally by the framework.
Declared In
SCTableViewModel.h
autoAssignDataSourceForDetailModels
When TRUE, the model automatically assigns the dataSource of all detail models to the same value of its own data source. This option should be used carefully as setting it to TRUE will trigger all implemented dataSource methods for all detail models in the heirarchy. Default: FALSE.
@property (nonatomic, readwrite) BOOL autoAssignDataSourceForDetailModels
Declared In
SCTableViewModel.h
autoAssignDelegateForDetailModels
When TRUE, the model automatically assigns the delegate of all detail models to the same value of its own delegate. This option should be used carefully as setting it to TRUE will trigger all implemented delegate methods for all detail models in the heirarchy. Default: FALSE.
@property (nonatomic, readwrite) BOOL autoAssignDelegateForDetailModels
Declared In
SCTableViewModel.h
autoGenerateSectionIndexTitles
If TRUE, SCTableViewModel will automatically generate the sectionIndexTitles array from the first letter of each section’s header title. Default: FALSE.
@property (nonatomic, readwrite) BOOL autoGenerateSectionIndexTitles
Declared In
SCTableViewModel.h
autoResizeForKeyboard
If TRUE, SCTableViewModel will automatically resize its tableView when the keyboard appears. Property defualts to FALSE if viewController is a UITableViewController subclass, as UITableViewController will automatically handle the resizing. Otherwise, it defaults to TRUE.
@property (nonatomic, readwrite) BOOL autoResizeForKeyboard
Declared In
SCTableViewModel.h
autoSortSections
If TRUE, SCTableViewModel will automatically sort its sections alphabetically according to their header title value. To provide custom section sorting, implement the tableViewModel:sortSections: SCTableViewDataSource method instead. Default: FALSE.
@property (nonatomic, readwrite) BOOL autoSortSections
Declared In
SCTableViewModel.h
cellActions
The set of cell action blocks that get applied to all the model’s cells.
@property (nonatomic, readonly) SCCellActions *cellActions
Discussion
Note: Cell actions defined in the model’s individual cells will override any actions set here.
Declared In
SCTableViewModel.h
commitButton
‘SCTableViewModel’ will automatically enable/disable the commitButton based on the valuesAreValid property, where commitButton is enabled if valuesAreValid is TRUE.
@property (nonatomic, strong) UIBarButtonItem *commitButton
Declared In
SCTableViewModel.h
dataSource
The object that acts as the data source of ‘SCTableViewModel’. The object must adopt the SCTableViewModelDataSource protocol.
@property (nonatomic, unsafe_unretained) id dataSource
Declared In
SCTableViewModel.h
delegate
The object that acts as the delegate of ‘SCTableViewModel’. The object must adopt the SCTableViewModelDelegate protocol.
@property (nonatomic, unsafe_unretained) id delegate
Declared In
SCTableViewModel.h
detailViewController
When set to a valid view controller, the model will use this controller to display all of its automatically generated detail views. This property is typically set in iPad applications where the model and its detailViewController co-exist in a UISplitViewController.
@property (nonatomic, strong) UIViewController *detailViewController
Discussion
Warning: detailViewController must be of type SCViewController or SCTableViewController only.
Declared In
SCTableViewModel.h
editButtonItem
When set to a valid UIBarButtonItem, SCTableViewModel automatically puts its table view in edit mode when the button is tapped. Note: Must be set if the model is to automatically show/hide editing mode sections.
@property (nonatomic, strong) UIBarButtonItem *editButtonItem
Declared In
SCTableViewModel.h
enablePullToRefresh
Set to TRUE to enable pull-to-refresh functionality on the table view. Default: FALSE.
@property (nonatomic, readwrite) BOOL enablePullToRefresh
See Also
Declared In
SCTableViewModel.h
hideSectionHeaderTitles
If TRUE, all section header titles will be hidden. Default: FALSE.
@property (nonatomic, readwrite) BOOL hideSectionHeaderTitles
Declared In
SCTableViewModel.h
inputAccessoryView
The keyboard input accessory view responsible for providing keyboard navigation between the different responders. Set to nil to disable the accessory view functionality.
@property (nonatomic, strong) SCInputAccessoryView *inputAccessoryView
Declared In
SCTableViewModel.h
live
Returns true if the modeled table view is live and displaying cells.
@property (nonatomic, readonly) BOOL live
Declared In
SCTableViewModel.h
lockCellSelection
If TRUE, SCTableViewModel will prevent any cell from being selected. Default: FALSE.
@property (nonatomic, readwrite) BOOL lockCellSelection
Discussion
Note: for preventing individual cells from being selected, use SCTableViewCell “selectable” property.
Declared In
SCTableViewModel.h
masterModel
Property is used internally by the framework to set the master model in a master-detail relationship.
@property (nonatomic, unsafe_unretained) SCTableViewModel *masterModel
Declared In
SCTableViewModel.h
modelActions
The set of model action blocks.
@property (nonatomic, readonly) SCModelActions *modelActions
Declared In
SCTableViewModel.h
modeledTableView
The UITableView bound to ‘SCTableViewModel’.
@property (nonatomic, unsafe_unretained) UITableView *modeledTableView
Discussion
Warning: This property has been deprecated. Use tableView instead.
Declared In
SCTableViewModel.h
needsCommit
This property is TRUE if any of the model's cells or sections needs to be commited, otherwise it's FALSE.
@property (nonatomic, readonly) BOOL needsCommit
Declared In
SCTableViewModel.h
pullToRefreshView
Contains a valid SCPullToRefreshView that automatically provides pull-to-refresh functionality to the table view.
@property (nonatomic, strong) SCPullToRefreshView *pullToRefreshView
Discussion
Note: enablePullToRefresh must be set to TRUE for this view to take effect.
Declared In
SCTableViewModel.h
sectionActions
The set of section action blocks that get applied to all the model’s sections.
@property (nonatomic, readonly) SCSectionActions *sectionActions
Discussion
Note: Section actions defined in the model’s individual sections will override any actions set here.
Declared In
SCTableViewModel.h
sectionCount
The number of sections in the model.
@property (nonatomic, readonly) NSUInteger sectionCount
Declared In
SCTableViewModel.h
sectionIndexTitles
An array of strings that serve as the title of sections in the tableView and appear in the index list on the right side of the tableView. tableView must be in plain style for the index to appear.
@property (nonatomic, strong) NSArray *sectionIndexTitles
Declared In
SCTableViewModel.h
swipeToDeleteActive
Property is used internally by the framework to determine if the table view is in swipe-to-delete editing mode.
@property (nonatomic, readonly) BOOL swipeToDeleteActive
Declared In
SCTableViewModel.h
tableView
The UITableView bound to 'SCTableViewModel'.
@property (nonatomic, unsafe_unretained) UITableView *tableView
Declared In
SCTableViewModel.h
tag
An integer that you can use to identify different table view models in your application. Any detail model automatically gets its tag set to be the value of its parent model’s tag plus one. Default: 0.
@property (nonatomic, readwrite) NSInteger tag
Declared In
SCTableViewModel.h
theme
The theme used to style the model’s views. Default: nil.
@property (nonatomic, strong) SCTheme *theme
Declared In
SCTableViewModel.h
Class Methods
modelWithTableView:
Allocates and returns an initialized SCTableViewModel bound to a UITableView.
+ (id)modelWithTableView:(UITableView *)tableView
Parameters
- tableView
The UITableView to be bound to the model. It’s ok for this value to be nil if the table view is not yet available when the model is created.
Discussion
Upon the model’s initialization, the model sets itself as the table view’s dataSource and delegate, and starts providing it with its sections and cells.
Declared In
SCTableViewModel.h
Instance Methods
addSection:
Adds a new section to the model.
- (void)addSection:(SCTableViewSection *)section
Parameters
- section
Must be a valid non nil SCTableViewSection.
Declared In
SCTableViewModel.h
cellAfterCell:rewind:
Returns the cell that comes after the specified cell in the model.
- (SCTableViewCell *)cellAfterCell:(SCTableViewCell *)cell rewind:(BOOL)rewind
Parameters
- cell
Must be a valid non nil SCTableViewCell.
- rewind
If TRUE and cell is the very last cell in the model, method returns the cell at the very top.
Return Value
Returns nil if cell is the last cell in the model and rewind is FALSE, or if cell does not exist in the model.
Declared In
SCTableViewModel.h
cellAtIndexPath:
Returns the cell at the specified indexPath.
- (SCTableViewCell *)cellAtIndexPath:(NSIndexPath *)indexPath
Parameters
- indexPath
Must be a valid non nil NSIndexPath.
Declared In
SCTableViewModel.h
cellBeforeCell:rewind:
Returns the cell that comes before the specified cell in the model.
- (SCTableViewCell *)cellBeforeCell:(SCTableViewCell *)cell rewind:(BOOL)rewind
Parameters
- cell
Must be a valid non nil SCTableViewCell.
- rewind
If TRUE and cell is the very first cell in the model, method returns the last cell.
Return Value
Returns nil if cell is the last cell in the model and rewind is FALSE, or if cell does not exist in the model.
See Also
Declared In
SCTableViewModel.h
clearLastReturnedCellData
Warning: Method must only be called internally by the framework.
- (void)clearLastReturnedCellData
Declared In
SCTableViewModel.h
commitChanges
Forces the commit of all section and cell values into their respective bound objects. There is usually no need to call this method manually as it’s typically called by the framework when the user is ready to commit changes.
- (void)commitChanges
Declared In
SCTableViewModel.h
configureCell:atIndexPath:
Method called internally.
- (void)configureCell:(SCTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
Declared In
SCTableViewModel.h
configureDetailModel:
Warning: Method must only be called internally by the framework.
- (void)configureDetailModel:(SCTableViewModel *)detailModel
Declared In
SCTableViewModel.h
didTapEditButtonItem
Subclasses should override this method to handle when editButtonItem is tapped.
- (void)didTapEditButtonItem
Declared In
SCTableViewModel.h
dismissAllDetailViewsWithCommit:
Dismisses all detail views, commiting all changes when commit is TRUE, otherwise it will ignore all changes.
- (void)dismissAllDetailViewsWithCommit:(BOOL)commit
Declared In
SCTableViewModel.h
enterLoadingMode
Warning: Method must only be called internally by the framework.
- (void)enterLoadingMode
Declared In
SCTableViewModel.h
exitLoadingMode
Warning: Method must only be called internally by the framework.
- (void)exitLoadingMode
Declared In
SCTableViewModel.h
generateSectionsForObject:withDataStore:
Generates sections using the given object and its data store.
- (void)generateSectionsForObject:(NSObject *)object withDataStore:(SCDataStore *)store
Parameters
- object
The object that the sections will be generated for.
- store
The object’s data store.
Declared In
SCTableViewModel.h
generateSectionsForObject:withDataStore:newObject:
Generates sections using the given object and its data store.
- (void)generateSectionsForObject:(NSObject *)object withDataStore:(SCDataStore *)store newObject:(BOOL)newObject
Parameters
- object
The object that the sections will be generated for.
- store
The object’s data store.
- newObject
Set to TRUE if the generated sections are used represent a newly created fresh object, otherwise set to FALSE.
Declared In
SCTableViewModel.h
generateSectionsForObject:withDefinition:
Generates sections using the given object and its data definition. The method fully utilizes the definition’s groups feature by generating a section for each group.
- (void)generateSectionsForObject:(NSObject *)object withDefinition:(SCDataDefinition *)definition
Parameters
- object
The object that the sections will be generated for.
- definition
The object’s definition.
Discussion
Warning: Important: definition must be the data definition representing the given object.
Declared In
SCTableViewModel.h
generateSectionsForObject:withDefinition:newObject:
Generates sections using the given object and its data definition. The method fully utilizes the definition’s groups feature by generating a section for each group.
- (void)generateSectionsForObject:(NSObject *)object withDefinition:(SCDataDefinition *)definition newObject:(BOOL)newObject
Parameters
- object
The object that the sections will be generated for.
- definition
The object’s definition.
- newObject
Set to TRUE if the generated sections are used represent a newly created fresh object, otherwise set to FALSE.
Discussion
Warning: Important: definition must be the data definition representing the given object.
Declared In
SCTableViewModel.h
generateSectionsForUserDefaultsDefinition:
Generates sections using a user defaults definition.
- (void)generateSectionsForUserDefaultsDefinition:(SCUserDefaultsDefinition *)userDefaultsDefinition
Declared In
SCTableViewModel.h
generateSectionsForiCloudKeyValueDefinition:
Generates table view sections using an iCloud key-value definition.
- (void)generateSectionsForiCloudKeyValueDefinition:(SCiCloudKeyValueDefinition *)iCloudKeyValueDefinition
Declared In
SCTableViewModel+iCloud.h
indexForSection:
Returns the index of the specified section.
- (NSUInteger)indexForSection:(SCTableViewSection *)section
Parameters
- section
Must be a valid non nil SCTableViewSection.
Return Value
If section is not found, method returns NSNotFound.
Declared In
SCTableViewModel.h
indexPathForCell:
Returns the index path for the specified cell.
- (NSIndexPath *)indexPathForCell:(SCTableViewCell *)cell
Parameters
- cell
Must be a valid non nil SCTableViewCell.
Return Value
If cell is not found, method returns NSNotFound.
Declared In
SCTableViewModel.h
indexPathForCellAfterCell:rewind:
Returns the indexPath of the cell that comes after the specified cell in the model.
- (NSIndexPath *)indexPathForCellAfterCell:(SCTableViewCell *)cell rewind:(BOOL)rewind
Parameters
- cell
Must be a valid non nil SCTableViewCell.
- rewind
If TRUE and cell is the very last cell in the model, method returns the indexPath of the cell at the very top.
Return Value
Returns nil if cell is the last cell in the model and rewind is FALSE, or if cell does not exist in the model.
Declared In
SCTableViewModel.h
indexPathForCellAfterCellAtIndexPath:rewind:
Returns the indexPath of the cell that comes after the specified cell in the model.
- (NSIndexPath *)indexPathForCellAfterCellAtIndexPath:(NSIndexPath *)indexPath rewind:(BOOL)rewind
Parameters
- indexPath
The indexPath of the current cell.
- rewind
If TRUE and cell is the very last cell in the model, method returns the indexPath of the cell at the very top.
Return Value
Returns nil if cell is the last cell in the model and rewind is FALSE, or if cell does not exist in the model.
Declared In
SCTableViewModel.h
indexPathForCellBeforeCell:rewind:
Returns the indexPath of the cell that comes before the specified cell in the model.
- (NSIndexPath *)indexPathForCellBeforeCell:(SCTableViewCell *)cell rewind:(BOOL)rewind
Parameters
- cell
Must be a valid non nil SCTableViewCell.
- rewind
If TRUE and cell is the very first cell in the model, method returns the indexPath of the last cell.
Return Value
Returns nil if cell is the last cell in the model and rewind is FALSE, or if cell does not exist in the model.
See Also
Declared In
SCTableViewModel.h
indexPathForCellBeforeCellAtIndexPath:rewind:
Returns the indexPath of the cell that comes before the specified cell in the model.
- (NSIndexPath *)indexPathForCellBeforeCellAtIndexPath:(NSIndexPath *)indexPath rewind:(BOOL)rewind
Parameters
- indexPath
The indexPath of the current cell.
- rewind
If TRUE and cell is the very first cell in the model, method returns the indexPath of the last cell.
Return Value
Returns nil if cell is the last cell in the model and rewind is FALSE, or if cell does not exist in the model.
Declared In
SCTableViewModel.h
initWithTableView:
Returns an initialized ‘SCTableViewModel’ bound to a UITableView.
- (id)initWithTableView:(UITableView *)tableView
Parameters
- tableView
The UITableView to be bound to the model. It’s ok for this value to be nil if the table view is not yet available when the model is created.
Discussion
Upon the model’s initialization, the model sets itself as the table view’s dataSource and delegate, and starts providing it with its sections and cells.
Declared In
SCTableViewModel.h
insertSection:atIndex:
Inserts a new section at the specified index.
- (void)insertSection:(SCTableViewSection *)section atIndex:(NSUInteger)index
Parameters
- section
Must be a valid non nil SCTableViewSection.
- index
Must be less than the total number of sections.
Declared In
SCTableViewModel.h
keyboardWillHide:
Warning: Method must only be called internally by the framework.
- (void)keyboardWillHide:(NSNotification *)aNotification
Declared In
SCTableViewModel.h
keyboardWillShow:
Warning: Method must only be called internally by the framework.
- (void)keyboardWillShow:(NSNotification *)aNotification
Declared In
SCTableViewModel.h
moveToNextCellControl:
Moves the first responder to the next cell control, automatically scrolling the table view as needed. If rewind is TRUE, the first responder is moved to the very first cell after the last cell has been reached.
- (void)moveToNextCellControl:(BOOL)rewind
Discussion
Note: This method is typically used when you’re overriding the framework’s automatic handling of the keyboard’s ‘Return’ button.
Declared In
SCTableViewModel.h
moveToPreviousCellControl:
Moves the first responder to the previous cell control, automatically scrolling the table view as needed. If rewind is TRUE, the first responder is moved to the very last cell after the first cell has been reached.
- (void)moveToPreviousCellControl:(BOOL)rewind
Declared In
SCTableViewModel.h
pullToRefreshViewDidStartLoading
Method called by pullToRefreshView to initiate refresh.
- (void)pullToRefreshViewDidStartLoading
Declared In
SCTableViewModel.h
reloadBoundValues
Reload’s the model’s bound values in case the associated bound objects or keys valuea has changed by means other than the cells themselves (e.g. external custom code).
- (void)reloadBoundValues
Declared In
SCTableViewModel.h
removeAllSections
Removes all sections from the model.
- (void)removeAllSections
Declared In
SCTableViewModel.h
removeSectionAtIndex:
Removes the section at the specified index from the model.
- (void)removeSectionAtIndex:(NSUInteger)index
Parameters
- index
Must be less than the total number of section.
Declared In
SCTableViewModel.h
sectionAtIndex:
Returns the section at the specified index.
- (SCTableViewSection *)sectionAtIndex:(NSUInteger)index
Parameters
- index
Must be less than the total number of sections.
Declared In
SCTableViewModel.h
sectionWithHeaderTitle:
Returns the first section with the specified header title.
- (SCTableViewSection *)sectionWithHeaderTitle:(NSString *)title
Parameters
- title
The header title.
Declared In
SCTableViewModel.h
setActiveCell:
Warning: Method must only be called internally by the framework.
- (void)setActiveCell:(SCTableViewCell *)cell
Declared In
SCTableViewModel.h
setActiveCellControl:
Warning: Method must only be called internally by the framework.
- (void)setActiveCellControl:(UIResponder *)control
Declared In
SCTableViewModel.h
setModeledTableViewEditing:animated:
Sets the editing mode for tableView.
- (void)setModeledTableViewEditing:(BOOL)editing animated:(BOOL)animate
Discussion
Warning: This method has been deprecated. Use setTableViewEditing:animated: instead.
Declared In
SCTableViewModel.h
setTableViewEditing:animated:
Sets the editing mode for tableView.
- (void)setTableViewEditing:(BOOL)editing animated:(BOOL)animate
Declared In
SCTableViewModel.h
setTargetForModelModifiedEvent:action:
Method used internally by the framework to monitor model modification events.
- (void)setTargetForModelModifiedEvent:(id)_target action:(SEL)_action
Declared In
SCTableViewModel.h
styleCell:atIndexPath:
Method called internally.
- (void)styleCell:(SCTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
Declared In
SCTableViewModel.h
styleCell:atIndexPath:onlyStylePropertyNamesInSet:
Method called internally.
- (void)styleCell:(SCTableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath onlyStylePropertyNamesInSet:(NSSet *)propertyNames
Declared In
SCTableViewModel.h
valueChangedForRowAtIndexPath:
Method gets called internally whenever the value of a cell changes. This method should only be used when subclassing ‘SCTableViewModel’. If what you want is to get notified when a cell value changes, consider using either SCTableViewModelDelegate or the cell’s actions.
- (void)valueChangedForRowAtIndexPath:(NSIndexPath *)indexPath
Parameters
- indexPath
Index path of the cell changed.
Discussion
When subclassing ‘SCTableViewModel’, you can override this method to define custom behaviour when a cell value changes. However, you should always call “[super valueChangedForRowAtIndexPath:]” somewhere in your subclassed method.
Declared In
SCTableViewModel.h
valueChangedForSectionAtIndex:
Method gets called internally whenever the value of a section changes. This method should only be used when subclassing ‘SCTableViewModel’. If what you want is to get notified when a section value changes, consider using SCTableViewModelDelegate methods.
- (void)valueChangedForSectionAtIndex:(NSUInteger)index
Parameters
- index
Index of the section changed.
Discussion
When subclassing ‘SCTableViewModel’, you can override this method to define custom behaviour when a section value changes. However, you should always call “[super valueChangedForSectionAtIndex:]” somewhere in your subclassed method.
Declared In
SCTableViewModel.h