Skip to content

Commit

Permalink
Added Swift-Codable-Struct with forced unwrapped option
Browse files Browse the repository at this point in the history
  • Loading branch information
mumer92 committed Dec 26, 2017
1 parent 16893c7 commit e40b258
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 4 deletions.
2 changes: 1 addition & 1 deletion JSONExport/FileRepresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class FileRepresenter{
fileContent += ". All rights reserved.\n"
}

fileContent += "//\tModel file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport"
// fileContent += "//\tModel file generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport"

if let langAuthor = lang.author{
fileContent += "\n\n//\tThe \"\(lang.displayLangName!)\" support has been made available by \(langAuthor.name!)"
Expand Down
2 changes: 1 addition & 1 deletion JSONExport/HeaderFileRepresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class HeaderFileRepresenter : FileRepresenter{
}

fileContent += ". All rights reserved.\n//\n\n"
fileContent += "//\tModel file Generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport\n\n"
//fileContent += "//\tModel file Generated using JSONExport: https://github.com/Ahmed-Ali/JSONExport\n\n"
}

}
Expand Down
105 changes: 105 additions & 0 deletions JSONExport/Swift-Codable-Unwrapped.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"modelStart": "{\n",
"importForEachCustomType": "",
"reservedKeywords": [
"abstract",
"assert",
"boolean",
"break",
"byte",
"case",
"catch",
"char",
"class",
"const",
"continue",
"default",
"do",
"double",
"else",
"enum",
"extends",
"false",
"final",
"finally",
"float",
"for",
"goto",
"if",
"implements",
"import",
"instanceof",
"int",
"interface",
"long",
"native",
"new",
"null",
"package",
"private",
"protected",
"public",
"return",
"short",
"static",
"strictfp",
"super",
"switch",
"synchronized",
"this",
"throw",
"throws",
"transient",
"true",
"try",
"void",
"volatile",
"while",
"class",
"description"
],
"booleanGetter": "",
"briefDescription": "Defines how your JSON objects can be mapped to Swift structures using the built-in NSJSONSerialization class",
"utilityMethods": [
],
"dataTypes": {
"stringType": "String",
"boolType": "Bool",
"floatType": "Float",
"doubleType": "Double",
"characterType": "Character",
"longType": "Double",
"intType": "Int"
},
"wordsToRemoveToGetArrayElementsType": [
"[",
"]"
],
"constructors": [
{
"fetchBasicTypeWithSpecialNeedsPropertyFromMap": "",
"bodyStart": "{\n",
"body": "",
"bodyEnd": "\t}\n",
"fetchBasicTypePropertyFromMap": "\t\tcase <!VarName!> = \"<!JsonKeyName!>\"\n",
"signature": "\tenum CodingKeys: String, CodingKey ",
"fetchArrayOfCustomTypePropertyFromMap": "\t\tcase <!VarName!> = \"<!JsonKeyName!>\"\n",
"comment": "",
"fetchCustomTypePropertyFromMap": "\t\tcase <!VarName!>\n"
}
],
"modelDefinition": "\nstruct <!ModelName!> : Codable ",
"genericType": "AnyObject",
"getter": "",
"setter": "",
"fileExtension": "swift",
"arrayType": "[<!ElementType!>]",
"basicTypesWithSpecialFetchingNeeds": [
],
"displayLangName": "Swift - Struct - Codable - Unwrapped",
"instanceVarDefinition": "\tlet <!VarName!> : <!VarType!>\n",
"supportsFirstLineStatement": "false",
"modelEnd": "\n}",
"staticImports": "import Foundation",
"langName": "Swift"
}
4 changes: 2 additions & 2 deletions JSONExport/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
saveButton.isEnabled = false
var str = sourceText.string!

if str.characters.count == 0{
if str.count == 0{
runOnUiThread{
//Nothing to do, just clear any generated files
self.files.removeAll(keepingCapacity: false)
Expand All @@ -397,7 +397,7 @@ class ViewController: NSViewController, NSUserNotificationCenterDelegate, NSTabl
return;
}
var rootClassName = classNameField.stringValue
if rootClassName.characters.count == 0{
if rootClassName.count == 0{
rootClassName = "RootClass"
}
sourceText.isEditable = false
Expand Down

0 comments on commit e40b258

Please sign in to comment.