SCArrayOfItemsSection
@interface SCArrayOfItemsSection
: SCTableViewSection <SCViewControllerDelegate,
SCTableViewControllerDelegate> {
BOOL _isFetchingItems;
BOOL itemsInSync;
SCTableViewModel *activeDetailModel;
NSMutableArray *cellReuseIdentifiers;
NSObject *tempItem;
SCDataStore *dataStore;
SCDataFetchOptions *dataFetchOptions;
BOOL autoFetchItems;
UITableViewCellAccessoryType itemsAccessoryType;
BOOL allowAddingItems;
BOOL allowDeletingItems;
BOOL allowMovingItems;
BOOL allowEditDetailView;
BOOL allowRowSelection;
BOOL skipNewItemDetailView;
BOOL autoSelectNewItemCell;
NSString *cellIdentifier;
UIBarButtonItem *addButtonItem;
SCTableViewCell *placeholderCell;
SCTableViewCell *addNewItemCell;
BOOL addNewItemCellExistsInNormalMode;
BOOL addNewItemCellExistsInEditingMode;
}
This class functions as an SCTableViewModel section that is able to represent an array of any kind of items and automatically generate its cells from these items. The section is also able to handle all end-user interaction with the generated cells, including adding, editing, deleting, and moving the cells. When cells are added or edited, detail views are automatically generated for this purpose. To enable adding cells, the class’ user should set the addButtonItem property of the section to a valid UIBarButtonItem, the section then will automatically add new items when the button is tapped.
When adding new items to the array, the section starts by first asking the model’s data source to provide a new item using its tableViewModel:newItemForArrayOfItemsSectionAtIndex: SCTableViewModelDataSource protocol method.
This class is an abstract base class. Subclasses of this class must override the buildDetailTableModel method. This method should return a model for the detail view to display.
Warning
This is an abstract base class, you should never make any direct instances of it.
See
SCArrayOfStringsSection, SCArrayOfObjectsSection.
-
Undocumented
Declaration
Objective-C
BOOL _isFetchingItems
-
Undocumented
Declaration
Objective-C
BOOL itemsInSync
-
Unavailable
Undocumented
Declaration
Objective-C
__weak SCTableViewModel *activeDetailModel
-
Undocumented
Declaration
Objective-C
NSMutableArray *cellReuseIdentifiers
-
Undocumented
Declaration
Objective-C
NSObject *tempItem
-
Undocumented
Declaration
Objective-C
SCDataStore *dataStore
-
Undocumented
Declaration
Objective-C
SCDataFetchOptions *dataFetchOptions
-
Undocumented
Declaration
Objective-C
BOOL autoFetchItems
-
Undocumented
Declaration
Objective-C
UITableViewCellAccessoryType itemsAccessoryType
-
Undocumented
Declaration
Objective-C
BOOL allowAddingItems
-
Undocumented
Declaration
Objective-C
BOOL allowDeletingItems
-
Undocumented
Declaration
Objective-C
BOOL allowMovingItems
-
Undocumented
Declaration
Objective-C
BOOL allowEditDetailView
-
Undocumented
Declaration
Objective-C
BOOL allowRowSelection
-
Undocumented
Declaration
Objective-C
BOOL skipNewItemDetailView
-
Undocumented
Declaration
Objective-C
BOOL autoSelectNewItemCell
-
Undocumented
Declaration
Objective-C
NSString *cellIdentifier
-
Undocumented
Declaration
Objective-C
UIBarButtonItem *addButtonItem
-
Undocumented
Declaration
Objective-C
SCTableViewCell *placeholderCell
-
Undocumented
Declaration
Objective-C
SCTableViewCell *addNewItemCell
-
Undocumented
Declaration
Objective-C
BOOL addNewItemCellExistsInNormalMode
-
Undocumented
Declaration
Objective-C
BOOL addNewItemCellExistsInEditingMode
-
Allocates and returns an initialized ‘SCArrayOfItemsSection’ given a data store.
Declaration
Objective-C
+ (instancetype)sectionWithHeaderTitle:(NSString *)sectionHeaderTitle dataStore:(SCDataStore *)store;
Parameters
sectionHeaderTitle
A header title for the section.
store
The data store containing the section’s items.
-
Returns an initialized ‘SCArrayOfItemsSection’ given a data store.
Declaration
Objective-C
- (instancetype)initWithHeaderTitle:(NSString *)sectionHeaderTitle dataStore:(SCDataStore *)store;
Parameters
sectionHeaderTitle
A header title for the section.
store
The data store containing the section’s items.
-
The data store that’s used to store and fetch the section’s items.
Declaration
Objective-C
@property (nonatomic, strong) SCDataStore *dataStore;
-
The options used to fetch the section’s items from dataStore.
Declaration
Objective-C
@property (nonatomic, strong) SCDataFetchOptions *dataFetchOptions;
-
The items fetched from dataStore.
Declaration
Objective-C
@property (nonatomic, readonly) NSArray *items;
-
Set to FALSE to disable the section from automatically fetching its items from dataStore. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL autoFetchItems;
-
This property is TRUE when the section is in a state of fetching its items from their dataStore.
Declaration
Objective-C
@property (nonatomic, readonly) BOOL isFetchingItems;
-
The accessory type of the generated cells.
Declaration
Objective-C
@property (nonatomic) UITableViewCellAccessoryType itemsAccessoryType;
-
Automatically hides section if it has no items. Default: FALSE.
Declaration
Objective-C
@property (nonatomic) BOOL hideWhenEmpty;
-
Allows/disables adding new cells/items to the items array. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL allowAddingItems;
-
Allows/disables deleting new cells/items from the items array. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL allowDeletingItems;
-
Allows/disables moving cells/items from one row to another. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL allowMovingItems;
-
Allows/disables a detail view for editing items’ values. Default: TRUE.
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.
Declaration
Objective-C
@property (nonatomic) BOOL allowEditDetailView;
-
Allows/disables row selection. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL allowRowSelection;
-
Set to TRUE to directly add the new item without displaying a detail view. This is useful in situations where the item details will be filled in programmatically by implementing the SCTableViewModelDelegate ‘tableViewModel:itemAddedForSectionAtIndexPath:item:’ method. Default: FALSE.
Declaration
Objective-C
@property (nonatomic) BOOL skipNewItemDetailView;
-
Allows/disables automatic cell selection of newly created items. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL autoSelectNewItemCell;
-
Automatically commits any changes to detail model. Set to FALSE if you’re planning to commit the changes yourself, or if detail model is in read-only mode. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL autoCommitDetailModelChanges;
-
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.
See
addNewItemCellDeclaration
Objective-C
@property (nonatomic, strong) UIBarButtonItem *addButtonItem;
-
This cell is automatically displayed when more section items need to be fetched. This is typically the case when the section’s dataFetchOptions has specified a batchSize.
Declaration
Objective-C
@property (nonatomic, strong) SCFetchItemsCell *fetchItemsCell;
-
When set to a valid cell object, ‘placeholderCell’ will be displayed when no items exist in the section. As soon as any items are added, this cell automatically disappears. Default: nil.
Declaration
Objective-C
@property (nonatomic, strong) SCTableViewCell *placeholderCell;
-
When set to a valid cell object, ‘addNewItemCell’ will be displayed as the last cell of the section, and will add a new item to the section whenever it gets tapped by the user. This cell can be used as an alternative to addButtonItem. Default: nil.
See
addButtonItemDeclaration
Objective-C
@property (nonatomic, strong) SCTableViewCell *addNewItemCell;
-
When TRUE, addNewItemCell will be displayed in Normal Mode. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL addNewItemCellExistsInNormalMode;
-
When TRUE, addNewItemCell will be displayed in Editing Mode. Default: TRUE.
Declaration
Objective-C
@property (nonatomic) BOOL addNewItemCellExistsInEditingMode;
-
User can call this method to dispatch an AddNewItem event, the same event dispached when the end-user taps addButtonItem.
Declaration
Objective-C
- (void)dispatchEventAddNewItem;
-
User can call this method to dispatch a SelectRow event, the same event dispached when the end-user selects a cell.
Declaration
Objective-C
- (void)dispatchEventSelectRowAtIndexPath:(NSIndexPath *)indexPath;
-
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.
Declaration
Objective-C
- (void)dispatchEventRemoveRowAtIndexPath:(NSIndexPath *)indexPath;
-
Called internally by framework to store the currently selected cell index path.
Declaration
Objective-C
@property (nonatomic, strong) NSIndexPath *selectedCellIndexPath;
-
Subclasses should use this property when creating new dequeable cells
Declaration
Objective-C
@property (nonatomic, copy) NSString *cellIdentifier;
-
Undocumented
Declaration
Objective-C
@property (nonatomic, copy) NSString *ibNewItemViewControllerIdentifier
-
Used internally by the framework.
Declaration
Objective-C
- (NSMutableArray *)mutableItems;
-
Used internally by the framework.
Declaration
Objective-C
- (void)setMutableItems:(NSMutableArray *)mutableItems;
-
Used internally by the framework.
Declaration
Objective-C
- (void)fetchItems:(id)sender;
-
Used internally by the framework.
Declaration
Objective-C
- (void)didFetchItems:(NSArray *)fetchedItems sender:(id)sender;
-
Used internally by the framework.
Declaration
Objective-C
- (void)addSpecialCellsToItems;
-
Used internally by the framework.
Declaration
Objective-C
- (void)removeSpecialCellsFromItems;
-
Subclasses should override this method to handle the creation of section cells
Declaration
Objective-C
- (SCTableViewCell *)createCellAtIndex:(NSUInteger)index usingCellId:(NSString *)cellId;
-
Subclasses should override this method to manage setting the properties cells after being dequed from the table view
Declaration
Objective-C
- (void)setPropertiesForCell:(SCTableViewCell *)cell withIndex:(NSUInteger)index;
-
Subclasses should override this method to set the text for each generated cell
Declaration
Objective-C
- (NSString *)textForCellAtIndex:(NSUInteger)index;
-
Subclasses should override this method to set the detail text for each generated cell
Declaration
Objective-C
- (NSString *)detailTextForCellAtIndex:(NSUInteger)index;
-
Method is called internally when the generated cells are selected
Declaration
Objective-C
- (void)didSelectCellAtIndexPath:(NSIndexPath *)indexPath;
-
Method is called internally when the generated cells will deselect
Declaration
Objective-C
- (void)willDeselectCellAtIndexPath:(NSIndexPath *)indexPath;
-
Subclasses should override this method to handle when generated cells are deleted
Declaration
Objective-C
- (void)commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forCellAtIndexPath:(NSIndexPath *)indexPath;
-
Subclasses should override this method to handle when generated cells are about to move.
Declaration
Objective-C
- (NSIndexPath *) targetIndexPathForMoveFromCellAtIndexPath:(NSIndexPath *)sourceIndexPath toProposedIndexPath:(NSIndexPath *)proposedIndexPath;
-
Subclasses should override this method to handle when generated cells are moved
Declaration
Objective-C
- (void)moveCellAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath;
-
Subclasses should override this method to handle when addButtonItem is tapped
Declaration
Objective-C
- (void)didTapAddButtonItem;
-
Subclasses should override this method to handle creating a new item
Declaration
Objective-C
- (NSObject *)createNewItem;
-
Subclasses must override this method to build a model for the generated detail view.
- - parameter: detailTableModel This is an empty model. Method should add sections and cells to this model.
- - parameter: item The item that the model should be built for. If item is nil, a model should be built for a new item.
Declaration
Objective-C
- (void)buildDetailTableModel:(SCTableViewModel *)detailTableModel forItem:(NSObject *)item;
-
Subclasses must override this method to configure the generated detail view.
- - parameter: detailViewController The generated detail view.
- - parameter: item The item that the detail view is generated for.
- - parameter: newItem TRUE if the item is a newly created item.
Declaration
Objective-C
- (void)configureDetailViewController:(UIViewController *)detailViewController item:(NSObject *)item newItem:(BOOL)newItem;
-
Subclasses must override this method to configure the model for the generated detail view.
- - parameter: detailTableModel The model to be configured.
- - parameter: item The item that the model is configured for.
Declaration
Objective-C
- (void)configureDetailTableModel:(SCTableViewModel *)detailTableModel forItem:(NSObject *)item;
-
Subclasses must override this method to determine the navigation bar type of the detail view for the given item.
Declaration
Objective-C
- (SCNavigationBarType)getDetailViewNavigationBarTypeForItem:(NSObject *)item newItem:(BOOL)newItem;
-
Commits the newly created item.
Declaration
Objective-C
- (void)commitNewItem:(NSObject *)newItem detailModel:(SCTableViewModel *)detailModel;
-
Subclasses should override this method to handle adding a cell for newItem (method called internally by framework)
Declaration
Objective-C
- (void)addCellForNewItem:(NSObject *)newItem;
-
Subclasses should override this method to handle an item getting modified (method called internally by framework)
Declaration
Objective-C
- (void)itemModified:(NSObject *)item;
-
Subclasses should override this method to handle an item that got removed (method called internally by framework)
Declaration
Objective-C
- (void)itemRemovedAtIndex:(NSInteger)index;
-
Method gets called internally by framework.
Declaration
Objective-C
- (void)commitAndProcessChangesForDetailModel:(SCTableViewModel *)detailModel;