Fixes a bug editing a new monster.

This commit is contained in:
2020-10-09 22:04:28 -07:00
parent 5da0ee2549
commit 3d54342687
2 changed files with 11 additions and 5 deletions

View File

@@ -38,9 +38,14 @@
-(void)updateView {
self.textField.text = _selectedChoice.label;
NSInteger selectedRow = [_choices indexOfObject:_selectedChoice];
[self.pickerView selectRow:selectedRow inComponent:0 animated:YES];
if (_choices && _choices.count > 0) {
NSInteger selectedRow = [_choices indexOfObject:_selectedChoice];
if (selectedRow != NSNotFound) {
[self.pickerView selectRow:selectedRow inComponent:0 animated:YES];
} else {
[self.pickerView selectRow:0 inComponent:0 animated:YES];
}
}
}
@synthesize choices = _choices;
@@ -90,7 +95,8 @@
if (!_choices) {
newValue = value;
} else if (!foundChoice) {
newValue = nil;
foundChoice = [_choices firstObject];
newValue = foundChoice.value;
} else {
newValue = foundChoice.value;
}