Closed 3lvis closed 7 years ago
It's pretty straighforward:
tapping "clear" button triggers this method in FORMFieldValuesTableViewController
- (void)clearButtonDidTap {
FORMFieldValue *fieldValue = [FORMFieldValue new];
fieldValue.value = @NO;
if ([self.delegate respondsToSelector:@selector(fieldValuesTableViewController:didSelectedValue:)]) {
[self.delegate fieldValuesTableViewController:self
didSelectedValue:fieldValue];
}
}
Compare it with the one triggered when user selects one of the rows:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
FORMFieldValue *fieldValue = self.values[indexPath.row];
if ([self.delegate respondsToSelector:@selector(fieldValuesTableViewController:didSelectedValue:)]) {
[self.delegate fieldValuesTableViewController:self
didSelectedValue:fieldValue];
}
}
So, in this case, the value is being picked among some valid values.
In the former case, a new value is created and propagated further through the chain.
In case of select-style table (not DatePicker), the delegate is FORMSelectFieldCell
, so here is the method triggered:
- (void)fieldValuesTableViewController:(FORMFieldValuesTableViewController *)fieldValuesTableViewController
didSelectedValue:(FORMFieldValue *)selectedValue {
self.field.value = selectedValue;
[self updateWithField:self.field];
[self validate];
[fieldValuesTableViewController dismissViewControllerAnimated:YES completion:nil];
if ([self.delegate respondsToSelector:@selector(fieldCell:updatedWithField:)]) {
[self.delegate fieldCell:self updatedWithField:self.field];
}
}
So, now the newly created field has been set. Comparison with that field, that has only value, but doesn't have an id
triggers crash.
More info: https://github.com/hyperoslo/Form/pull/553