Changes Cheat.name to non-optional
This commit is contained in:
parent
007092f875
commit
9a186ffea9
@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14460.32" systemVersion="18A391" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14460.32" systemVersion="18B75" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||
<entity name="Cheat" representedClassName="Cheat" syncable="YES">
|
||||
<attribute name="code" attributeType="String" syncable="YES"/>
|
||||
<attribute name="creationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="isEnabled" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="modifiedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Transformable" syncable="YES">
|
||||
<userInfo>
|
||||
<entry key="attributeValueClassName" value="CheatType"/>
|
||||
|
||||
@ -24,7 +24,7 @@ public class _Cheat: NSManagedObject
|
||||
|
||||
@NSManaged public var modifiedDate: Date
|
||||
|
||||
@NSManaged public var name: String?
|
||||
@NSManaged public var name: String
|
||||
|
||||
@NSManaged public var type: CheatType
|
||||
|
||||
|
||||
@ -18,11 +18,11 @@ extension EmulatorCore
|
||||
}
|
||||
catch EmulatorCore.CheatError.invalid
|
||||
{
|
||||
print("Invalid cheat:", cheat.name ?? "Unnamed Cheat", cheat.code)
|
||||
print("Invalid cheat:", cheat.name, cheat.code)
|
||||
}
|
||||
catch
|
||||
{
|
||||
print("Unknown Cheat Error:", error, cheat.name ?? "Unnamed Cheat", cheat.code)
|
||||
print("Unknown Cheat Error:", error, cheat.name, cheat.code)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ extension CheatValidator
|
||||
{
|
||||
case invalidCode
|
||||
case invalidName
|
||||
case invalidGame
|
||||
case duplicateName
|
||||
case duplicateCode
|
||||
}
|
||||
@ -28,7 +29,10 @@ struct CheatValidator
|
||||
|
||||
func validate(_ cheat: Cheat) throws
|
||||
{
|
||||
guard let name = cheat.name, let game = cheat.game else { throw Error.invalidName }
|
||||
let name = cheat.name
|
||||
guard !name.isEmpty else { throw Error.invalidName }
|
||||
|
||||
guard let game = cheat.game else { throw Error.invalidGame }
|
||||
|
||||
let code = cheat.code
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user