SCSelectionModel Class Reference
Inherits from | SCArrayOfStringsModel : SCArrayOfObjectsModel : SCArrayOfItemsModel : SCTableViewModel : NSObject |
Declared in | SCTableViewModel.h |
Overview
This class functions as a model that is able to provide selection functionality. The cells in this model represent different items that the end-user can select from, and they are generated from NSStrings in its items array. Once a cell is selected, a checkmark appears next to it, similar to Apple’s Settings application where a user selects a Ringtone for their iPhone. The section can be configured to allow multiple selection and to allow no selection at all.
Since this model is based on SCArrayOfStringsModel, it supports automatically generated sections and automatic search functionality.
There are three ways to set/retrieve the section’s selection: – Through binding an object to the model, and specifying a property name to bind the selection index result to. The bound property must be of type NSMutableSet if multiple selection is allowed, otherwise it must be of type NSNumber or NSString. – Through the selectedItemsIndexes or selectedItemIndex properties.
Tasks
Creation and Initialization
-
– initWithTableView:boundObject:selectedIndexPropertyName:items:
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, an NSNumber bound property name, and an array of selection items.
-
– initWithTableView:boundObject:selectedIndexesPropertyName:items:allowMultipleSelection:
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, a bound property name, an array of selection items, and whether to allow multiple selection.
-
– initWithTableView:boundObject:selectionStringPropertyName:items:
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, an NSString bound property name, and an array of selection items.
Configuration
-
boundObject
The model’s bound object.
property -
boundObjectStore
The model’s bound object store.
property -
boundPropertyName
The model’s bound property name.
property -
boundValue
The model’s bound value.
property -
selectedItemIndex
This property reflects the current section’s selection. You can set this property to define the section’s selection.
property -
selectedItemsIndexes
This property reflects the current section’s selection(s). You can add index(es) to the set to define the section’s selection.
property -
allowMultipleSelection
If TRUE, the section allows multiple selection. Default: FALSE.
property -
allowNoSelection
If TRUE, the section allows no selection at all. Default: FALSE.
property -
maximumSelections
The maximum number of items that can be selected. Set to zero to allow an infinite number of selections. Default: 0. @note: Only applicable when allowMultipleSelection is TRUE.
property -
autoDismissViewController
If TRUE, the section automatically dismisses the current view controller when a value is selected. Default: FALSE.
property
Properties
allowMultipleSelection
If TRUE, the section allows multiple selection. Default: FALSE.
@property (nonatomic, readwrite) BOOL allowMultipleSelection
Declared In
SCTableViewModel.h
allowNoSelection
If TRUE, the section allows no selection at all. Default: FALSE.
@property (nonatomic, readwrite) BOOL allowNoSelection
Declared In
SCTableViewModel.h
autoDismissViewController
If TRUE, the section automatically dismisses the current view controller when a value is selected. Default: FALSE.
@property (nonatomic, readwrite) BOOL autoDismissViewController
Declared In
SCTableViewModel.h
boundObject
The model’s bound object.
@property (nonatomic, readonly) NSObject *boundObject
Declared In
SCTableViewModel.h
boundObjectStore
The model’s bound object store.
@property (nonatomic, strong) SCDataStore *boundObjectStore
Declared In
SCTableViewModel.h
boundPropertyName
The model’s bound property name.
@property (nonatomic, readonly) NSString *boundPropertyName
Declared In
SCTableViewModel.h
boundValue
The model’s bound value.
@property (nonatomic, strong) NSObject *boundValue
Declared In
SCTableViewModel.h
maximumSelections
The maximum number of items that can be selected. Set to zero to allow an infinite number of selections. Default: 0. @note: Only applicable when allowMultipleSelection is TRUE.
@property (nonatomic, readwrite) NSUInteger maximumSelections
Declared In
SCTableViewModel.h
selectedItemIndex
This property reflects the current section’s selection. You can set this property to define the section’s selection.
@property (nonatomic, copy) NSNumber *selectedItemIndex
Discussion
Note: If you have bound this section to an object or a key, you can define the section’s selection using either the bound property value or the key value, respectively.
Note: In case of no selection, this property will be set to an NSNumber of value -1.
Declared In
SCTableViewModel.h
selectedItemsIndexes
This property reflects the current section’s selection(s). You can add index(es) to the set to define the section’s selection.
@property (nonatomic, readonly) NSMutableSet *selectedItemsIndexes
Discussion
Note: If you have bound this section to an object or a key, you can define the section’s selection using either the bound property value or the key value, respectively.
Declared In
SCTableViewModel.h
Instance Methods
initWithTableView:boundObject:selectedIndexPropertyName:items:
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, an NSNumber bound property name, and an array of selection items.
- (id)initWithTableView:(UITableView *)tableView boundObject:(NSObject *)object selectedIndexPropertyName:(NSString *)propertyName items:(NSArray *)sectionItems
Parameters
- tableView
The UITableView to be bound to the model.
- object
The object the model will bind to.
- propertyName
The property name present in the bound object that the section will bind to and will automatically change the value of to reflect the model’s current selection. This property must be of type NSNumber and can’t be a readonly property. The model will also initialize its selection from the value present in this property.
- sectionItems
An array of the items that the user will choose from. All items must be of an NSString type.
Declared In
SCTableViewModel.h
initWithTableView:boundObject:selectedIndexesPropertyName:items:allowMultipleSelection:
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, a bound property name, an array of selection items, and whether to allow multiple selection.
- (id)initWithTableView:(UITableView *)tableView boundObject:(NSObject *)object selectedIndexesPropertyName:(NSString *)propertyName items:(NSArray *)sectionItems allowMultipleSelection:(BOOL)multipleSelection
Parameters
- tableView
The UITableView to be bound to the model.
- object
The object the model will bind to.
- propertyName
The property name present in the bound object that the model will bind to and will automatically change the value of to reflect the model’s current selection(s). This property must be of type NSMutableSet. The model will also initialize its selection(s) from the value present in this property. Every item in this set must be an NSNumber that represent the index of the selected cell(s).
- sectionItems
An array of the items that the user will choose from. All items must be of an NSString type.
- multipleSelection
Determines if multiple selection is allowed.
Declared In
SCTableViewModel.h
initWithTableView:boundObject:selectionStringPropertyName:items:
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, an NSString bound property name, and an array of selection items.
- (id)initWithTableView:(UITableView *)tableView boundObject:(NSObject *)object selectionStringPropertyName:(NSString *)propertyName items:(NSArray *)sectionItems
Parameters
- tableView
The UITableView to be bound to the model.
- object
The object the model will bind to.
- propertyName
The property name present in the bound object that the model will bind to and will automatically change the value of to reflect the model’s current selection. This property must be of type NSString and can’t be a readonly property. The model will also initialize its selection from the value present in this property.
- sectionItems
An array of the items that the user will choose from. All items must be of an NSString type.
Declared In
SCTableViewModel.h