SCSelectionModel
@interface SCSelectionModel : SCArrayOfStringsModel {
BOOL boundToNSNumber;
BOOL boundToNSString;
NSIndexPath *lastSelectedRowIndexPath;
NSObject *boundObject;
SCDataStore *boundObjectStore;
NSString *boundPropertyName;
BOOL allowMultipleSelection;
BOOL allowNoSelection;
NSUInteger maximumSelections;
BOOL autoDismissViewController;
NSMutableSet *_selectedItemsIndexes;
}
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.
See
SCSelectionSection.
-
Undocumented
Declaration
Objective-C
BOOL boundToNSNumber
-
Undocumented
Declaration
Objective-C
BOOL boundToNSString
-
Undocumented
Declaration
Objective-C
NSIndexPath *lastSelectedRowIndexPath
-
Undocumented
Declaration
Objective-C
NSObject *boundObject
-
Undocumented
Declaration
Objective-C
SCDataStore *boundObjectStore
-
Undocumented
Declaration
Objective-C
NSString *boundPropertyName
-
Undocumented
Declaration
Objective-C
BOOL allowMultipleSelection
-
Undocumented
Declaration
Objective-C
BOOL allowNoSelection
-
Undocumented
Declaration
Objective-C
NSUInteger maximumSelections
-
Undocumented
Declaration
Objective-C
BOOL autoDismissViewController
-
Undocumented
Declaration
Objective-C
NSMutableSet *_selectedItemsIndexes
-
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, an NSNumber bound property name, and an array of selection items.
Declaration
Objective-C
- (instancetype)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.
-
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.
Declaration
Objective-C
- (instancetype)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.
-
Returns an initialized ‘SCSelectionModel’ given a table view, a bound object, an NSString bound property name, and an array of selection items.
Declaration
Objective-C
- (instancetype)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.
-
The model’s bound object.
Declaration
Objective-C
@property (nonatomic, readonly) NSObject *boundObject;
-
The model’s bound object store.
Declaration
Objective-C
@property (nonatomic, strong) SCDataStore *boundObjectStore;
-
The model’s bound property name.
Declaration
Objective-C
@property (nonatomic, readonly) NSString *boundPropertyName;
-
The model’s bound value.
Declaration
Objective-C
@property (nonatomic, strong) NSObject *boundValue;
-
This property reflects the current section’s selection. You can set this property to define the section’s selection.
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.Declaration
Objective-C
@property (nonatomic, copy) NSNumber *selectedItemIndex;
-
This property reflects the current section’s selection(s). You can add index(es) to the set to define the section’s selection.
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.Declaration
Objective-C
@property (nonatomic, readonly) NSMutableSet *selectedItemsIndexes;
-
If TRUE, the section allows multiple selection. Default: FALSE.
Declaration
Objective-C
@property (nonatomic) BOOL allowMultipleSelection;
-
If TRUE, the section allows no selection at all. Default: FALSE.
Declaration
Objective-C
@property (nonatomic) BOOL allowNoSelection;
-
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.
Declaration
Objective-C
@property (nonatomic) NSUInteger maximumSelections;
-
If TRUE, the section automatically dismisses the current view controller when a value is selected. Default: FALSE.
Declaration
Objective-C
@property (nonatomic) BOOL autoDismissViewController;