SCCustomCell Class Reference
Inherits from | SCTableViewCell : UITableViewCell |
Conforms to | UITextFieldDelegate UITextViewDelegate |
Declared in | SCTableViewCell.h |
Overview
This class functions as a base class for all user defined custom cells.
The following is a summary of each control that can be automatically bound, in addition to the corresponding boundObject property value type that it must be associated with:
- UILabel: NSString, NSNumber, NSDate
- UITextField: NSString, NSNumber, NSDate
- UITextView: NSString, NSNumber, NSDate
- UISlider: NSNumber, NSString
- UISegmentedControl: NSNumber, NSString
- UISwitch: NSNumber
Tasks
Creation and Initialization
-
+ cellWithText:objectBindings:nibName:
Allocates and returns an initialized ‘SCCustomCell’ given cell text, custom object bindings, and a nib file name. Use this type of constructor in cases where the bound object is not yet known and will be provided later by the framework. A common case is when implementing the SCTableViewModelDataSource method called ‘tableViewModel:cellForRowAtIndexPath:’.
-
+ cellWithText:objectBindingsString:nibName:
Allocates and returns an initialized ‘SCCustomCell’ given cell text, custom object bindings string, and a nib file name. Use this type of constructor in cases where the bound object is not yet known and will be provided later by the framework. A common case is when implementing the SCTableViewModelDataSource method called ‘tableViewModel:cellForRowAtIndexPath:’.
-
+ cellWithText:boundObject:objectBindings:nibName:
Allocates and returns an initialized ‘SCControlCell’ given cell text, bound object, custom object bindings, and a nib file name.
Configuration
-
objectBindings
This dictionary specifies how each of the cell’s custom controls binds itself to the boundObject’s properties.
property -
objectBindingsString
This string specifies how each of the cell’s custom controls binds itself to the boundObject’s properties. The string should consist of a colon separated pair of control’s tag and the property name, while each pair should be separated by a semi-colon.
property -
autoResize
propertyDetermines if cell should automatically resize to fit its contents. Default: TRUE.
-
showClearButtonInInputAccessoryView
Show the ‘Clear’ button in the model’s inputAccessoryView.
property
Managing Custom Control Values
-
– controlWithTag:
Returns the control with the given tag value. Returns nil if controlTag is less than 1.
-
– boundValueForControlWithTag:
Returns the bound value for the control with the given tag value. Returns nil if controlTag is less than 1.
-
– commitValueForControlWithTag:value:
Commits the bound value for the control with the given tag value.
Internal Methods (should only be used by the framework or when subclassing)
-
inputControlsSortedByTag
An array of all the cell’s input controls sorted by their tag value. Property is used internally by the framework.
property -
– configureCustomControls
Method must be called by subclasses to configure any added custom controls for automatic binding.
-
– loadBindingsIntoCustomControls
Method called internally by framework.
-
– textFieldEditingChanged:
Method gets called internally whenever the value of a UITextField control is changed.
-
– sliderValueChanged:
Method gets called internally whenever the value of a UISlider control is changed.
-
– segmentedControlValueChanged:
Method gets called internally whenever the value of a UISegmentedControl is changed.
-
– switchControlChanged:
Method gets called internally whenever the value of a UISwitch control is changed.
-
– customButtonTapped:
Method gets called internally whenever the a custom button is tapped.
Properties
autoResize
Determines if cell should automatically resize to fit its contents. Default: TRUE.
@property (nonatomic, readwrite) BOOL autoResize
Declared In
SCTableViewCell.h
inputControlsSortedByTag
An array of all the cell’s input controls sorted by their tag value. Property is used internally by the framework.
@property (nonatomic, readonly) NSArray *inputControlsSortedByTag
Declared In
SCTableViewCell.h
objectBindings
This dictionary specifies how each of the cell’s custom controls binds itself to the boundObject’s properties.
@property (nonatomic, readonly) NSMutableDictionary *objectBindings
Discussion
Each dictionary key should be the tag string value of one of the cell’s custom controls, and the value should be the name of the boundObject’s property that is bound to that control.
Warning: All control tags must be greater than zero.
Note: This property can be used interchangibly with objectBindingsString
Declared In
SCTableViewCell.h
objectBindingsString
This string specifies how each of the cell’s custom controls binds itself to the boundObject’s properties. The string should consist of a colon separated pair of control’s tag and the property name, while each pair should be separated by a semi-colon.
@property (nonatomic, copy) NSString *objectBindingsString
Discussion
Example bindings string:
NSString *bindingsString = @"1:firstName;2:lastName";
Warning: IMPORTANT: All control tags must be greater than zero.
Note: This property can be used interchangibly with objectBindings
Declared In
SCTableViewCell.h
Class Methods
cellWithText:boundObject:objectBindings:nibName:
Allocates and returns an initialized ‘SCControlCell’ given cell text, bound object, custom object bindings, and a nib file name.
+ (id)cellWithText:(NSString *)cellText boundObject:(NSObject *)object objectBindings:(NSDictionary *)bindings nibName:(NSString *)nibName
Parameters
- cellText
The text that will appear in the cell’s textLabel.
- object
The cell’s bound object (see SCTableViewCell class overview).
- bindings
The cell’s object bindings. This dictionary specifies how each of the cell’s custom controls binds itself to the boundObject’s properties. Each dictionary key should be the tag string value of one of the cell’s custom controls, and the value should be the name of the boundObject’s property that is bound to that control.
- nibName
The name of the nib file to load the cell from. The nib file should only contain one cell, and it should be a subclass of ‘SCControlCell’.
Discussion
Note: This constructor is usually used to construct custom cells that are either created in Interface Builder, or created by subclassing ‘SCControlCell’.
Warning: All control tags must be greater than zero.
Note: It’s ok for this parameter to be nil if the cell has no corresponding nib file.
Declared In
SCTableViewCell.h
cellWithText:objectBindings:nibName:
Allocates and returns an initialized ‘SCCustomCell’ given cell text, custom object bindings, and a nib file name. Use this type of constructor in cases where the bound object is not yet known and will be provided later by the framework. A common case is when implementing the SCTableViewModelDataSource method called ‘tableViewModel:cellForRowAtIndexPath:’.
+ (id)cellWithText:(NSString *)cellText objectBindings:(NSDictionary *)bindings nibName:(NSString *)nibName
Parameters
- cellText
The text that will appear in the cell’s textLabel.
- bindings
The cell’s object bindings. This dictionary specifies how each of the cell’s custom controls binds itself to its boundObject’s properties. Each dictionary key should be the tag string value of one of the cell’s custom controls, and the value should be the name of the boundObject’s property that is bound to that control.
- nibName
The name of the nib file to load the cell from. The nib file should only contain one cell, and it should be a subclass of ‘SCControlCell’.
Discussion
Note: This constructor is usually used to construct custom cells that are either created in Interface Builder, or created by subclassing ‘SCCustomCell’.
Warning: All control tags must be greater than zero.
Note: it’s ok for this parameter to be nil if the cell has no corresponding nib file.
Declared In
SCTableViewCell.h
cellWithText:objectBindingsString:nibName:
Allocates and returns an initialized ‘SCCustomCell’ given cell text, custom object bindings string, and a nib file name. Use this type of constructor in cases where the bound object is not yet known and will be provided later by the framework. A common case is when implementing the SCTableViewModelDataSource method called ‘tableViewModel:cellForRowAtIndexPath:’.
+ (id)cellWithText:(NSString *)cellText objectBindingsString:(NSString *)bindingsString nibName:(NSString *)nibName
Parameters
- cellText
The text that will appear in the cell’s textLabel.
- bindingsString
The cell’s object bindings string. This string specifies how each of the cell’s custom controls binds itself to its boundObject’s properties. The string’s format should be as follows: @“tag1:propertyName1;tag2:propertyName2;tag3:propertyName3”
- nibName
The name of the nib file to load the cell from. The nib file should only contain one cell, and it should be a subclass of ‘SCControlCell’.
Discussion
Note: This constructor is usually used to construct custom cells that are either created in Interface Builder, or created by subclassing ‘SCCustomCell’.
Warning: All control tags must be greater than zero.
Note: it’s ok for this parameter to be nil if the cell has no corresponding nib file.
Declared In
SCTableViewCell.h
Instance Methods
boundValueForControlWithTag:
Returns the bound value for the control with the given tag value. Returns nil if controlTag is less than 1.
- (NSObject *)boundValueForControlWithTag:(NSInteger)controlTag
Declared In
SCTableViewCell.h
commitValueForControlWithTag:value:
Commits the bound value for the control with the given tag value.
- (void)commitValueForControlWithTag:(NSInteger)controlTag value:(NSObject *)controlValue
Declared In
SCTableViewCell.h
configureCustomControls
Method must be called by subclasses to configure any added custom controls for automatic binding.
- (void)configureCustomControls
Declared In
SCTableViewCell.h
controlWithTag:
Returns the control with the given tag value. Returns nil if controlTag is less than 1.
- (UIView *)controlWithTag:(NSInteger)controlTag
Declared In
SCTableViewCell.h
customButtonTapped:
Method gets called internally whenever the a custom button is tapped.
- (void)customButtonTapped:(id)sender
Declared In
SCTableViewCell.h
loadBindingsIntoCustomControls
Method called internally by framework.
- (void)loadBindingsIntoCustomControls
Declared In
SCTableViewCell.h
segmentedControlValueChanged:
Method gets called internally whenever the value of a UISegmentedControl is changed.
- (void)segmentedControlValueChanged:(id)sender
Declared In
SCTableViewCell.h
sliderValueChanged:
Method gets called internally whenever the value of a UISlider control is changed.
- (void)sliderValueChanged:(id)sender
Declared In
SCTableViewCell.h