SCSelectionSection

@interface SCSelectionSection : SCArrayOfStringsSection {
  BOOL boundToNSNumber;
  BOOL boundToNSString;
  NSIndexPath *lastSelectedRowIndexPath;
  BOOL allowMultipleSelection;
  BOOL allowNoSelection;
  NSUInteger maximumSelections;
  BOOL autoDismissViewController;
  NSMutableSet *_selectedItemsIndexes;
}

This class functions as an SCTableViewModel section that is able to provide selection functionality. The cells in this section 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.

There are three ways to set/retrieve the section’s selection:

  • Through binding an object to the section, 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 binding a key to the section and setting/retrieving through the ownerTableViewModel modelKeyValues property.
  • Through the selectedItemsIndexes or selectedItemIndex properties.

See

SCSelectionCell.

Creation and Initialization

  • Allocates and returns an initialized ‘SCSelectionSection’ given a header title, a bound object, an NSNumber bound property name, and an array of selection items.

    Declaration

    Objective-C

    + (instancetype)sectionWithHeaderTitle:(NSString *)sectionHeaderTitle
                               boundObject:(NSObject *)object
                 selectedIndexPropertyName:(NSString *)propertyName
                                     items:(NSArray *)sectionItems;

    Parameters

    sectionHeaderTitle

    A header title for the section.

    object

    The object the section 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 section’s current selection. This property must be of type NSNumber and can’t be a readonly property. The section 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.

  • Allocates and returns an initialized ‘SCSelectionSection’ given a header title, a bound object, an NSMutableSet bound property name, an array of selection items, and wether to allow multiple selection.

    Declaration

    Objective-C

    + (instancetype)sectionWithHeaderTitle:(NSString *)sectionHeaderTitle
                               boundObject:(NSObject *)object
               selectedIndexesPropertyName:(NSString *)propertyName
                                     items:(NSArray *)sectionItems
                    allowMultipleSelection:(BOOL)multipleSelection;

    Parameters

    sectionHeaderTitle

    A header title for the section.

    object

    The object the section 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 section’s current selection(s). This property must be of type NSMutableSet. The section will also initialize its selection(s) 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.

    multipleSelection

    Determines if multiple selection is allowed.

  • Allocates and returns an initialized ‘SCSelectionSection’ given a header title, a bound object, an NSString bound property name, and an array of selection items.

    Declaration

    Objective-C

    + (instancetype)sectionWithHeaderTitle:(NSString *)sectionHeaderTitle
                               boundObject:(NSObject *)object
               selectionStringPropertyName:(NSString *)propertyName
                                     items:(NSArray *)sectionItems;

    Parameters

    sectionHeaderTitle

    A header title for the section.

    object

    The object the section 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 section’s current selection. This property must be of type NSString and can’t be a readonly property. The section 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 ‘SCSelectionSection’ given a header title, a bound object, an NSNumber bound property name, and an array of selection items.

    Declaration

    Objective-C

    - (instancetype)initWithHeaderTitle:(NSString *)sectionHeaderTitle
                            boundObject:(NSObject *)object
              selectedIndexPropertyName:(NSString *)propertyName
                                  items:(NSArray *)sectionItems;

    Parameters

    sectionHeaderTitle

    A header title for the section.

    object

    The object the section 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 section’s current selection. This property must be of type NSNumber and can’t be a readonly property. The section 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 ‘SCSelectionSection’ given a header title, a bound object, a bound property name, an array of selection items, and wether to allow multiple selection.

    Declaration

    Objective-C

    - (instancetype)initWithHeaderTitle:(NSString *)sectionHeaderTitle
                            boundObject:(NSObject *)object
            selectedIndexesPropertyName:(NSString *)propertyName
                                  items:(NSArray *)sectionItems
                 allowMultipleSelection:(BOOL)multipleSelection;

    Parameters

    sectionHeaderTitle

    A header title for the section.

    object

    The object the section 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 section’s current selection(s). This property must be of type NSMutableSet. The section 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 ‘SCSelectionSection’ given a header title, a bound object, an NSString bound property name, and an array of selection items.

    Declaration

    Objective-C

    - (instancetype)initWithHeaderTitle:(NSString *)sectionHeaderTitle
                            boundObject:(NSObject *)object
            selectionStringPropertyName:(NSString *)propertyName
                                  items:(NSArray *)sectionItems;

    Parameters

    sectionHeaderTitle

    A header title for the section.

    object

    The object the section 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 section’s current selection. This property must be of type NSString and can’t be a readonly property. The section 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.

Configuration

  • 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;
  • The text color of the selected cell(s).

    Declaration

    Objective-C

    @property (nonatomic, strong) UIColor *selectedCellTextColor;
  • The text color of the deselected cell(s).

    Declaration

    Objective-C

    @property (nonatomic, strong) UIColor *deselectedCellTextColor;

Internal Properties & Methods (should only be used by the framework or when subclassing)

  • ///////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////

    Declaration

    Objective-C

    - (void)configureCellForDisplay:(SCTableViewCell *)cell
                            atIndex:(NSUInteger)index;