SCArrayOfItemsModel Class Reference
Inherits from | SCTableViewModel : NSObject |
Conforms to | SCTableViewControllerDelegate UISearchBarDelegate |
Declared in | SCTableViewModel.h |
Overview
This class subclasses SCTableViewModel to represent an array of any kind of items and will automatically generate its cells from these items. ‘SCArrayOfItemsModel will automatically generate a set of SCArrayOfItemsSection(s) if either the sectionHeaderTitleForItem modelAction or SCTableViewModelDataSource method tableViewModel:sectionHeaderTitleForItem:AtIndex: is implemented, otherwise it will only generate a single SCArrayOfItemsSection.
Warning: This is an abstract base class, you should never make any direct instances of it.
Tasks
Creation and Initialization
-
– initWithTableView:dataStore:
Returns an initialized ‘SCArrayOfItemsModel given a UITableView and a data store.
Configuration
-
dataStore
The data store that’s used to store and fetch the model’s items.
property -
dataFetchOptions
property -
items
The items fetched from dataStore.
property -
autoFetchItems
Set to FALSE to disable the section from automatically fetching its items from dataStore. Default: TRUE.
property -
itemsAccessoryType
The accessory type of the generated cells.
property -
allowAddingItems
Allows/disables adding new cells/items to the items array. Default: TRUE.
property -
allowDeletingItems
Allows/disables deleting new cells/items from the items array. Default: TRUE.
property -
allowMovingItems
Allows/disables moving cells/items from one row to another. Default: FALSE.
property -
allowEditDetailView
Allows/disables a detail view for editing items' values. Default: TRUE.
property -
allowRowSelection
Allows/disables row selection. Default: TRUE.
property -
autoSelectNewItemCell
Allows/disables automatic cell selection of newly created items. Default: TRUE.
property -
addButtonItem
Set this property to a valid UIBarButtonItem. When addButtonItem is tapped and allowAddingItems is TRUE, a detail view is automatically generated for the user to enter the new items properties. If the properties are commited, a new item is added to the array.
property -
searchBar
The search bar associated with the model. Once set to a valid UISearchBar, the model will automatically filter its items based on the user’s typed search term.
property -
enableSearchDisplayController
Set to TRUE to use a UISearchDisplayController to perform searches. Default: FALSE.
property -
searchDisplayController
The UISearchDisplayController used to search the model values.
property -
detailViewControllerOptions
Options for the generated detail view controller.
property -
newItemDetailViewControllerOptions
Options for the generated detail view controller for new items.
property
Manual Event Control
-
– dispatchEventAddNewItem
User can call this method to dispatch an AddNewItem event, the same event dispached when the end-user taps addButtonItem.
-
– dispatchEventSelectRowAtIndexPath:
User can call this method to dispatch a SelectRow event, the same event dispached when the end-user selects a cell.
-
– dispatchEventRemoveRowAtIndexPath:
User can call this method to dispatch a RemoveRow event, the same event dispached when the end-user taps the delete button on a cell.
Internal Properties & Methods (should only be used by the framework or when subclassing)
-
– mutableItems
Used internally by the framework.
-
– setMutableItems:
Used internally by the framework.
-
– createSectionWithHeaderTitle:
Subclasses should override this method to handle section creation.
-
– setPropertiesForSection:
Subclasses should override this method to set additional section properties after creation.
-
– didTapAddButtonItem
Subclasses should override this method to handle when addButtonItem is tapped.
-
– addNewItem:
Method called internally by framework when the model should add a new item.
-
– itemModified:inSection:
Method called internally by framework when a model item has been modified.
-
– itemRemoved:inSection:
Method called internally by framework when a model item has been removed.
-
– invalidateItems
Method called internally by framework when the model’s items are out of sync with the data store.
-
– getSectionIndexForItem:
Method called internally by framework.
-
– setDetailViewControllerOptions:
Method called internally.
-
– setNewItemDetailViewControllerOptions:
Method called internally.
Properties
addButtonItem
Set this property to a valid UIBarButtonItem. When addButtonItem is tapped and allowAddingItems is TRUE, a detail view is automatically generated for the user to enter the new items properties. If the properties are commited, a new item is added to the array.
@property (nonatomic, strong) UIBarButtonItem *addButtonItem
Declared In
SCTableViewModel.h
allowAddingItems
@property (nonatomic, readwrite) BOOL allowAddingItems
Declared In
SCTableViewModel.h
allowDeletingItems
@property (nonatomic, readwrite) BOOL allowDeletingItems
Declared In
SCTableViewModel.h
allowEditDetailView
Allows/disables a detail view for editing items' values. Default: TRUE.
@property (nonatomic, readwrite) BOOL allowEditDetailView
Discussion
Detail views are automatically generated for editing new items. You can control wether the view appears as a modal view or gets pushed to the navigation stack using the detailViewModal property. Modal views have the added feature of giving the end user a Cancel and Done buttons. The Cancel button cancels all user’s actions, while the Done button commits them. Also, if the cell’s validation is enabled, the Done button will remain disabled until all cells' values are valid.
Declared In
SCTableViewModel.h
allowMovingItems
Allows/disables moving cells/items from one row to another. Default: FALSE.
@property (nonatomic, readwrite) BOOL allowMovingItems
Declared In
SCTableViewModel.h
allowRowSelection
Allows/disables row selection. Default: TRUE.
@property (nonatomic, readwrite) BOOL allowRowSelection
Declared In
SCTableViewModel.h
autoFetchItems
Set to FALSE to disable the section from automatically fetching its items from dataStore. Default: TRUE.
@property (nonatomic, readwrite) BOOL autoFetchItems
Declared In
SCTableViewModel.h
autoSelectNewItemCell
Allows/disables automatic cell selection of newly created items. Default: TRUE.
@property (nonatomic, readwrite) BOOL autoSelectNewItemCell
Declared In
SCTableViewModel.h
dataFetchOptions
@property (nonatomic, strong) SCDataFetchOptions *dataFetchOptions
Declared In
SCTableViewModel.h
dataStore
The data store that’s used to store and fetch the model’s items.
@property (nonatomic, strong) SCDataStore *dataStore
Declared In
SCTableViewModel.h
detailViewControllerOptions
Options for the generated detail view controller.
@property (nonatomic, readonly) SCDetailViewControllerOptions *detailViewControllerOptions
Declared In
SCTableViewModel.h
enableSearchDisplayController
Set to TRUE to use a UISearchDisplayController to perform searches. Default: FALSE.
@property (nonatomic, readwrite) BOOL enableSearchDisplayController
Discussion
@note: The searchBar property must be set to a valid UISearchBar control for this property to have any effect.
Declared In
SCTableViewModel.h
items
The items fetched from dataStore.
@property (nonatomic, readonly) NSArray *items
Declared In
SCTableViewModel.h
itemsAccessoryType
The accessory type of the generated cells.
@property (nonatomic, readwrite) UITableViewCellAccessoryType itemsAccessoryType
Declared In
SCTableViewModel.h
newItemDetailViewControllerOptions
Options for the generated detail view controller for new items.
@property (nonatomic, readonly) SCDetailViewControllerOptions *newItemDetailViewControllerOptions
Declared In
SCTableViewModel.h
searchBar
The search bar associated with the model. Once set to a valid UISearchBar, the model will automatically filter its items based on the user’s typed search term.
@property (nonatomic, strong) UISearchBar *searchBar
Declared In
SCTableViewModel.h
searchDisplayController
The UISearchDisplayController used to search the model values.
@property (nonatomic, strong, readonly) UISearchDisplayController *searchDisplayController
Discussion
@note: searchDisplayController only has value if enableSearchDisplayController is TRUE and a valid searchBar is set.
Declared In
SCTableViewModel.h
Instance Methods
addNewItem:
Method called internally by framework when the model should add a new item.
- (void)addNewItem:(NSObject *)newItem
Declared In
SCTableViewModel.h
createSectionWithHeaderTitle:
Subclasses should override this method to handle section creation.
- (SCArrayOfItemsSection *)createSectionWithHeaderTitle:(NSString *)title
Declared In
SCTableViewModel.h
didTapAddButtonItem
Subclasses should override this method to handle when addButtonItem is tapped.
- (void)didTapAddButtonItem
Declared In
SCTableViewModel.h
dispatchEventAddNewItem
User can call this method to dispatch an AddNewItem event, the same event dispached when the end-user taps addButtonItem.
- (void)dispatchEventAddNewItem
Declared In
SCTableViewModel.h
dispatchEventRemoveRowAtIndexPath:
User can call this method to dispatch a RemoveRow event, the same event dispached when the end-user taps the delete button on a cell.
- (void)dispatchEventRemoveRowAtIndexPath:(NSIndexPath *)indexPath
Declared In
SCTableViewModel.h
dispatchEventSelectRowAtIndexPath:
User can call this method to dispatch a SelectRow event, the same event dispached when the end-user selects a cell.
- (void)dispatchEventSelectRowAtIndexPath:(NSIndexPath *)indexPath
Declared In
SCTableViewModel.h
getSectionIndexForItem:
Method called internally by framework.
- (NSUInteger)getSectionIndexForItem:(NSObject *)item
Declared In
SCTableViewModel.h
initWithTableView:dataStore:
Returns an initialized ‘SCArrayOfItemsModel given a UITableView and a data store.
- (id)initWithTableView:(UITableView *)tableView dataStore:(SCDataStore *)store
Parameters
- tableView
The UITableView to be bound to the model.
- store
The data store containing the model’s items.
Declared In
SCTableViewModel.h
invalidateItems
Method called internally by framework when the model’s items are out of sync with the data store.
- (void)invalidateItems
Declared In
SCTableViewModel.h
itemModified:inSection:
Method called internally by framework when a model item has been modified.
- (void)itemModified:(NSObject *)item inSection:(SCArrayOfItemsSection *)section
Declared In
SCTableViewModel.h
itemRemoved:inSection:
Method called internally by framework when a model item has been removed.
- (void)itemRemoved:(NSObject *)item inSection:(SCArrayOfItemsSection *)section
Declared In
SCTableViewModel.h
mutableItems
Used internally by the framework.
- (NSMutableArray *)mutableItems
Declared In
SCTableViewModel.h
setDetailViewControllerOptions:
Method called internally.
- (void)setDetailViewControllerOptions:(SCDetailViewControllerOptions *)options
Declared In
SCTableViewModel.h
setMutableItems:
Used internally by the framework.
- (void)setMutableItems:(NSMutableArray *)mutableItems
Declared In
SCTableViewModel.h