From 61b9d0f1f8ee32735f1eb4b6aadf571b4becedad Mon Sep 17 00:00:00 2001 From: Daniel Davis Date: Mon, 12 Nov 2018 16:05:55 -0800 Subject: [PATCH] Remove optionals... because Pring. (#51) --- README.md | 2 +- langs/ios/ios.go | 6 +++--- .../TestFiremodelFromSchema/swift/Firemodel.swift | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0bea151..df5b3f0 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ This generated some Swift, some typescript and some go code. You'll find it in ` This is the standard firemodel workflow. Whenever you need to update your data model, you'll update the schema and regenerate the models. -## 3. Use the models +### 3. Use the models The models are designed to be idiomatic for their target languages and the official Firestone SDKs. diff --git a/langs/ios/ios.go b/langs/ios/ios.go index 4685a1e..cb9c943 100644 --- a/langs/ios/ios.go +++ b/langs/ios/ios.go @@ -117,19 +117,19 @@ func toSwiftType(root bool, firetype firemodel.SchemaFieldType) string { switch firetype := firetype.(type) { case *firemodel.Boolean: if root { - return "Bool?" + return "Bool = false" } else { return "Bool" } case *firemodel.Integer: if root { - return "Int?" + return "Int = 0" } else { return "Int" } case *firemodel.Double: if root { - return "Float?" + return "Float = 0" } else { return "Float" } diff --git a/testfixtures/firemodel/TestFiremodelFromSchema/swift/Firemodel.swift b/testfixtures/firemodel/TestFiremodelFromSchema/swift/Firemodel.swift index 9d3d6aa..5daf878 100644 --- a/testfixtures/firemodel/TestFiremodelFromSchema/swift/Firemodel.swift +++ b/testfixtures/firemodel/TestFiremodelFromSchema/swift/Firemodel.swift @@ -55,7 +55,7 @@ extension TestEnum: CustomDebugStringConvertible { // TODO: Add documentation to where in firemodel schema. var where: String? // TODO: Add documentation to how_much in firemodel schema. - var howMuch: Int? + var howMuch: Int = 0 // TODO: Add documentation to some_enum in firemodel schema. var someEnum: TestEnum? @@ -86,13 +86,13 @@ override class var path: String { return "test_models" } // The name. dynamic var name: String? // The age. - dynamic var age: Int? + dynamic var age: Int = 0 // The number pi. - dynamic var pi: Float? + dynamic var pi: Float = 0 // The birth date. dynamic var birthdate: Date? // True if it is good. - dynamic var isGood: Bool? + dynamic var isGood: Bool = false // TODO: Add documentation to data in firemodel schema. dynamic var data: Data? // TODO: Add documentation to friend in firemodel schema.