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

@@ -2,7 +2,7 @@
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17192" systemVersion="19H2" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" usedWithCloudKit="YES" userDefinedModelVersionIdentifier=""> <model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="17192" systemVersion="19H2" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" usedWithCloudKit="YES" userDefinedModelVersionIdentifier="">
<entity name="Monster" representedClassName="Monster" syncable="YES" codeGenerationType="category"> <entity name="Monster" representedClassName="Monster" syncable="YES" codeGenerationType="category">
<attribute name="alignment" attributeType="String" defaultValueString=""/> <attribute name="alignment" attributeType="String" defaultValueString=""/>
<attribute name="armorType" attributeType="String" defaultValueString=""/> <attribute name="armorType" attributeType="String" defaultValueString="none"/>
<attribute name="baseSpeed" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/> <attribute name="baseSpeed" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="burrowSpeed" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/> <attribute name="burrowSpeed" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="canHover" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/> <attribute name="canHover" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>

View File

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