Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fetchArrayFromJsonSyntaxForProperty bounds problem. #145

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d6f592d
Merge pull request #88 from AlexxNica/patch-1
Ahmed-Ali Nov 15, 2017
bf8134e
Merge pull request #96 from kashifshaikh/master
Ahmed-Ali Nov 15, 2017
16893c7
Merge pull request #93 from narlei/master
Ahmed-Ali Nov 15, 2017
c5a4da4
fix a complier error in SwiftyJSON - Class
superk589 Nov 27, 2017
779a06f
Migrate to Swift 4
serhii-londar Dec 13, 2017
e40b258
Added Swift-Codable-Struct with forced unwrapped option
mumer92 Dec 26, 2017
2f8ba42
added back credit file
mumer92 Dec 26, 2017
df54d97
Change generic type from 'AnyObject' to 'String' -> Fixes #105
Feb 12, 2018
8528d6a
Java Gson for Android: Fix method name to be "optString" instead of "…
Mar 3, 2018
02a96ed
Fix: float type issue
Mar 3, 2018
4c61a93
Update to Swift 4.2
BrychanOdlum Oct 2, 2018
0a3d17f
Updating GHANGELOG.md for release 1.0.9
Ahmed-Ali Nov 24, 2018
cdd8a4f
Merge branch 'master' of git://github.com/superk589/JSONExport into s…
Ahmed-Ali Nov 24, 2018
3b306da
Merge branch 'superk589-master' into develop
Ahmed-Ali Nov 24, 2018
30d8785
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
8e804f6
Merge branch 'master' of git://github.com/serhii-londar/JSONExport in…
Ahmed-Ali Nov 24, 2018
8069c92
Merge branch 'serhii-londar-master'
Ahmed-Ali Nov 24, 2018
a45d1ae
Merge branch 'serhii-londar-master' into develop
Ahmed-Ali Nov 24, 2018
c20cabb
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
2c3864f
Merge branch 'master' of git://github.com/mumer92/JSONExport into mum…
Ahmed-Ali Nov 24, 2018
330d94b
Merge branch 'mumer92-master' into develop
Ahmed-Ali Nov 24, 2018
9ca6bdc
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
a9b4ca0
Merge branch 'fix_generic_type_swift_struct_codable' of git://github.…
Ahmed-Ali Nov 24, 2018
870ee94
Merge branch 'ankushkushwaha-fix_generic_type_swift_struct_codable' i…
Ahmed-Ali Nov 24, 2018
0c5bd0d
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
790b7fb
Merge branch 'feature/fix_java_gson_for_android' of git://github.com/…
Ahmed-Ali Nov 24, 2018
96d1f27
Merge branch 'ty0521-fss-feature/fix_java_gson_for_android' into develop
Ahmed-Ali Nov 24, 2018
1e806c9
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
a0a7c7e
Merge branch 'master' of git://github.com/BrychanOdlum/JSONExport int…
Ahmed-Ali Nov 24, 2018
101a4e9
Merge branch 'BrychanOdlum-master' into develop
Ahmed-Ali Nov 24, 2018
87f71cb
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
a507ecf
Fixing the project file
Ahmed-Ali Nov 24, 2018
db500f5
Updating CHANGELOG.md
Ahmed-Ali Nov 24, 2018
47a897e
Adding Outlaw JSON file to the project as the merge conflicts caused …
Ahmed-Ali Nov 24, 2018
a0ec494
nit: removing empty line
Ahmed-Ali Nov 24, 2018
50e3f93
Fixed an issue with trying to figure the selected language from an UI…
Ahmed-Ali Nov 24, 2018
fe313c0
fixed: update the color under Dark Mode
Sep 6, 2019
ec2051d
Merge pull request #136 from hzb/master
huabin Sep 8, 2019
b88ee77
fix fetchArrayFromJsonSyntaxForProperty bounds problem.
xiaoMing0109 Aug 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,34 @@ JSONExport.xcodeproj/xcuserdata/ahmed.xcuserdatad/xcdebugger/Breakpoints_v2.xcbk
JSONExport.xcodeproj/project.xcworkspace/xcuserdata/ahmedali.xcuserdatad/UserInterfaceState.xcuserstate
JSONExport.xcodeproj/xcuserdata/ahmedali.xcuserdatad/xcschemes/JSONExport.xcscheme
JSONExport.xcodeproj/xcuserdata/ahmedali.xcuserdatad/xcschemes/xcschememanagement.plist


# OS X Finder
.DS_Store
.LSOverride

# Xcode per-user config
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
#*.xcworkspace
xcuserdata


# Build products
build/
*.o
*.LinkFileList
*.hmap

# Automatic backup files
*~.nib/
*.swp
*~
*.dat
*.dep

Breakpoints.xcbkptlist
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
* Version 1.1.0
- Merged PR #98 : fix a complier error in SwiftyJSON - Class. Thanks @superk589
- Merged PR #99 : Migrate to Swift 4. Thanks @serhii-londar
- Merged PR #101 : Added Codable Option to make Codable Structs with forced up-wrapped properties. Thanks @mumer92
- Merged PR #106 : Fix Xcode build-time error : Change generic type from 'AnyObject' to 'String' -> Fixes #105. Thanks @ankushkushwaha
- Merged PR #108 : Java Gson for Android: Fix method name. Thanks @ty0521-fss
- Merged PR #119 : Suuport for Outlaw. Thanks @LifetimeCode
- Merged PR #123 : Update to Swift 4.2. Thanks @BrychanOdlum
- Fixed an issue with trying to figure the selected language from an UI element outside the UI thread


* Version 1.0.9
- Merged PR #88 : Fix minor typo in the README.MD file. Thanks to @AlexxNica
- Merged PR #93 Changed app icon and fix upside down text. Thanks to @narlei
- Merged PR #96 Adding support for Swift 4 Codable. Thanks to @kashifshaikh

* Version 1.0.8
- Merged PR #72 App now remembers what language user selected last time. Thanks to @TParizek
- Merged PR #75 Fix Error for Swift in Xcode 8.2.1 and replace NSDictionary. Thanks to @dimohamdy
Expand Down
40 changes: 36 additions & 4 deletions JSONExport.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
01ACC24B1FBB42E300C410C2 /* Swift-Codable.json in Resources */ = {isa = PBXBuildFile; fileRef = 01ACC24A1FBB42E300C410C2 /* Swift-Codable.json */; };
166AF5CE1CEF6C3600516EDD /* Swift-Struct-Gloss.json in Resources */ = {isa = PBXBuildFile; fileRef = 166AF5CD1CEF6C3600516EDD /* Swift-Struct-Gloss.json */; };
608896441CF278440074CB80 /* Author.swift in Sources */ = {isa = PBXBuildFile; fileRef = 608896431CF278440074CB80 /* Author.swift */; };
60FB8FF01B9B361600290979 /* Java-Android Realm.json in Resources */ = {isa = PBXBuildFile; fileRef = 60FB8FE61B9B361600290979 /* Java-Android Realm.json */; };
Expand All @@ -29,6 +30,8 @@
E2197C5D1A0EAEB900549D03 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2197C5C1A0EAEB900549D03 /* StringExtension.swift */; };
E22BA2C51A162B54005CE143 /* FileContentBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E22BA2C41A162B54005CE143 /* FileContentBuilder.swift */; };
E230BA2C1A113F8C00AE2054 /* FilePreviewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E230BA2B1A113F8C00AE2054 /* FilePreviewCell.swift */; };
E24E443221AA12B800435FE7 /* Swift-Outlaw.json in Resources */ = {isa = PBXBuildFile; fileRef = E24E443021AA12B800435FE7 /* Swift-Outlaw.json */; };
E24E443321AA12B800435FE7 /* Swift3-Mappable.json in Resources */ = {isa = PBXBuildFile; fileRef = E24E443121AA12B800435FE7 /* Swift3-Mappable.json */; };
E278F9C61A2149AC00306EFC /* HeaderFileData.swift in Sources */ = {isa = PBXBuildFile; fileRef = E278F9C51A2149AC00306EFC /* HeaderFileData.swift */; };
E278F9CA1A2152D800306EFC /* HeaderFileRepresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = E278F9C91A2152D800306EFC /* HeaderFileRepresenter.swift */; };
E28631521A158CFA0041B178 /* Constructor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E286314E1A158CFA0041B178 /* Constructor.swift */; };
Expand All @@ -45,6 +48,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
01ACC24A1FBB42E300C410C2 /* Swift-Codable.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "Swift-Codable.json"; path = "Supported Languages/Swift-Codable.json"; sourceTree = "<group>"; };
166AF5CD1CEF6C3600516EDD /* Swift-Struct-Gloss.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "Swift-Struct-Gloss.json"; path = "Supported Languages/Swift-Struct-Gloss.json"; sourceTree = "<group>"; };
608896431CF278440074CB80 /* Author.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Author.swift; sourceTree = "<group>"; };
60FB8FE61B9B361600290979 /* Java-Android Realm.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "Java-Android Realm.json"; path = "Supported Languages/Java-Android Realm.json"; sourceTree = "<group>"; };
Expand All @@ -70,6 +74,8 @@
E2197C5C1A0EAEB900549D03 /* StringExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = "<group>"; };
E22BA2C41A162B54005CE143 /* FileContentBuilder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileContentBuilder.swift; sourceTree = "<group>"; };
E230BA2B1A113F8C00AE2054 /* FilePreviewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FilePreviewCell.swift; sourceTree = "<group>"; };
E24E443021AA12B800435FE7 /* Swift-Outlaw.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "Swift-Outlaw.json"; path = "Supported Languages/Swift-Outlaw.json"; sourceTree = "<group>"; };
E24E443121AA12B800435FE7 /* Swift3-Mappable.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = "Swift3-Mappable.json"; path = "Supported Languages/Swift3-Mappable.json"; sourceTree = "<group>"; };
E278F9C51A2149AC00306EFC /* HeaderFileData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderFileData.swift; sourceTree = "<group>"; };
E278F9C91A2152D800306EFC /* HeaderFileRepresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderFileRepresenter.swift; sourceTree = "<group>"; };
E286314E1A158CFA0041B178 /* Constructor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constructor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -151,6 +157,8 @@
E2F07E8A1A0B3192004A1DAA /* Supported Languages */ = {
isa = PBXGroup;
children = (
E24E443021AA12B800435FE7 /* Swift-Outlaw.json */,
E24E443121AA12B800435FE7 /* Swift3-Mappable.json */,
166AF5CD1CEF6C3600516EDD /* Swift-Struct-Gloss.json */,
60FB8FFA1B9B3F6400290979 /* ObjectiveC-Realm.json */,
A329A7EC1D5DA1ED00FB59E8 /* Java-Android Gson.json */,
Expand All @@ -165,6 +173,7 @@
60FB8FED1B9B361600290979 /* Swift-Mappable.json */,
60FB8FEE1B9B361600290979 /* Swift-Struct.json */,
98978FC01D5B6B19000C1846 /* Swift-Struct-Unbox.json */,
01ACC24A1FBB42E300C410C2 /* Swift-Codable.json */,
60FB8FEF1B9B361600290979 /* SwiftyJSON-Class.json */,
);
name = "Supported Languages";
Expand Down Expand Up @@ -252,12 +261,12 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Ahmed Ali";
TargetAttributes = {
E2FA87B41A059AC100648EB6 = {
CreatedOnToolsVersion = 6.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
};
};
};
Expand All @@ -284,12 +293,14 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
01ACC24B1FBB42E300C410C2 /* Swift-Codable.json in Resources */,
60FB8FF51B9B361600290979 /* Swift-Class.json in Resources */,
60FB8FF01B9B361600290979 /* Java-Android Realm.json in Resources */,
A329A7ED1D5DA1ED00FB59E8 /* Java-Android Gson.json in Resources */,
60FB8FF31B9B361600290979 /* ObjectiveC-iOS.json in Resources */,
60FB8FFC1B9B3F6400290979 /* ObjectiveC-Realm.json in Resources */,
60FB8FF11B9B361600290979 /* Java-Android.json in Resources */,
E24E443321AA12B800435FE7 /* Swift3-Mappable.json in Resources */,
60FB8FF81B9B361600290979 /* Swift-Struct.json in Resources */,
E2FA87BF1A059AC100648EB6 /* Images.xcassets in Resources */,
98978FC11D5B6B19000C1846 /* Swift-Struct-Unbox.json in Resources */,
Expand All @@ -299,6 +310,7 @@
60FB8FF91B9B361600290979 /* SwiftyJSON-Class.json in Resources */,
60FB8FF21B9B361600290979 /* ObjectiveC-CoreData-iOS.json in Resources */,
E2FA87C21A059AC100648EB6 /* Main.storyboard in Resources */,
E24E443221AA12B800435FE7 /* Swift-Outlaw.json in Resources */,
166AF5CE1CEF6C3600516EDD /* Swift-Struct-Gloss.json in Resources */,
60FB8FF41B9B361600290979 /* ObjectiveC-Mac.json in Resources */,
);
Expand Down Expand Up @@ -354,14 +366,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -389,6 +409,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
};
name = Debug;
};
Expand All @@ -400,14 +421,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -428,6 +457,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
};
name = Release;
};
Expand All @@ -443,7 +473,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "JSONExport/JSONExport-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -458,7 +489,8 @@
PRODUCT_BUNDLE_IDENTIFIER = "ahmed.ali.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "JSONExport/JSONExport-Bridging-Header.h";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>JSONExport.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
2 changes: 1 addition & 1 deletion JSONExport/FileContentBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class FilesContentBuilder{
str = str.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
var output = ""
var makeNextCharUpperCase = startFromFirstChar
for char in input.characters{
for char in input {
if char == "_" {
makeNextCharUpperCase = true
}else if makeNextCharUpperCase{
Expand Down
18 changes: 8 additions & 10 deletions JSONExport/FilePreviewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class FilePreviewCell: NSTableCellView, NSTextViewDelegate {
}

if self.file.includeConstructors{
self.constructors.state = NSOnState
self.constructors.state = NSControl.StateValue.on
}else{
self.constructors.state = NSOffState
self.constructors.state = NSControl.StateValue.off
}
if self.file.includeUtilities{
self.utilities.state = NSOnState
self.utilities.state = NSControl.StateValue.on
}else{
self.utilities.state = NSOffState
self.utilities.state = NSControl.StateValue.off
}
}
}else{
Expand Down Expand Up @@ -70,14 +70,14 @@ class FilePreviewCell: NSTableCellView, NSTextViewDelegate {
scrollView.hasVerticalRuler = true
scrollView.verticalRulerView = lineNumberView
scrollView.rulersVisible = true
textView.font = NSFont.userFixedPitchFont(ofSize: NSFont.smallSystemFontSize())
textView.font = NSFont.userFixedPitchFont(ofSize: NSFont.smallSystemFontSize)

}

@IBAction func toggleConstructors(_ sender: NSButtonCell)
{
if file != nil{
file.includeConstructors = (sender.state == NSOnState)
file.includeConstructors = (sender.state == NSControl.StateValue.off)
textView.string = file.toString()

}
Expand All @@ -86,14 +86,12 @@ class FilePreviewCell: NSTableCellView, NSTextViewDelegate {
@IBAction func toggleUtilityMethods(_ sender: NSButtonCell)
{
if file != nil{
file.includeUtilities = (sender.state == NSOnState)
file.includeUtilities = (sender.state == NSControl.StateValue.on)
textView.string = file.toString()
}
}

func textDidChange(_ notification: Notification) {
file.fileContent = textView.string ?? file.fileContent
file.fileContent = textView.string
}


}
46 changes: 42 additions & 4 deletions JSONExport/FileRepresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class FileRepresenter{
appendCustomImports()
//start the model defination
var definition = ""
if lang.modelDefinitionWithParent != nil && parentClassName.characters.count > 0{
if lang.modelDefinitionWithParent != nil && parentClassName.count > 0{
definition = lang.modelDefinitionWithParent.replacingOccurrences(of: modelName, with: className)
definition = definition.replacingOccurrences(of: modelWithParentClassName, with: parentClassName)
}else if includeUtilities && lang.defaultParentWithUtilityMethods != nil{
Expand Down Expand Up @@ -129,7 +129,7 @@ class FileRepresenter{
*/
func appendFirstLineStatement()
{
if lang.supportsFirstLineStatement != nil && lang.supportsFirstLineStatement! && firstLine.characters.count > 0{
if lang.supportsFirstLineStatement != nil && lang.supportsFirstLineStatement! && firstLine.count > 0{
fileContent += "\(firstLine)\n\n"
}
}
Expand Down Expand Up @@ -372,7 +372,18 @@ class FileRepresenter{
if let index = lang.basicTypesWithSpecialFetchingNeeds.index(of: property.type), let replacement = lang.basicTypesWithSpecialFetchingNeedsReplacements?[index]{
propertyHandlingStr = propertyHandlingStr.replacingOccurrences(of: varTypeReplacement, with: replacement)


var castString = String()
if let cast = lang.basicTypesWithSpecialFetchingNeedsTypeCast?[index]{
// if needs cast
if !cast.isEmpty {
castString = "(\(cast)) "
}
else {
castString = cast
}
}
propertyHandlingStr = propertyHandlingStr.replacingOccurrences(of: varTypeCast, with: castString)

let lowerCaseType = property.type.lowercased()
propertyHandlingStr = propertyHandlingStr.replacingOccurrences(of: lowerCaseVarType, with: lowerCaseType)

Expand Down Expand Up @@ -419,7 +430,7 @@ class FileRepresenter{
type = type.replacingOccurrences(of: arrayWord, with: "")
}

if type.characters.count == 0{
if type.count == 0{
type = typeNameForArrayElements(property.sampleValue as! NSArray, lang: lang)
}
return type
Expand Down Expand Up @@ -468,6 +479,21 @@ class FileRepresenter{
propertyStr = constructor.fetchArrayOfBasicTypePropertyFromMap
let replacement = lang.basicTypesWithSpecialFetchingNeedsReplacements[index]
propertyStr = propertyStr.replacingOccurrences(of: varTypeReplacement, with: replacement)

// if needs cast
guard
let casts = lang.basicTypesWithSpecialFetchingNeedsTypeCast,
!casts.isEmpty
else { return "" }

let cast = casts[index]
if !cast.isEmpty {
propertyStr = propertyStr.replacingOccurrences(of: varTypeCast, with: "(\(cast)) ")
}
else {
propertyStr = propertyStr.replacingOccurrences(of: varTypeCast, with: cast)
}

}else{
propertyStr = constructor.fetchBasicTypePropertyFromMap
}
Expand Down Expand Up @@ -500,6 +526,18 @@ class FileRepresenter{
propertyStr = propertyStr.replacingOccurrences(of: varTypeReplacement, with: replacement)
}

var castString = String()
if let cast = lang.basicTypesWithSpecialFetchingNeedsTypeCast?[index!]{
// if needs cast
if !cast.isEmpty {
castString = "(\(cast)) "
}
else {
castString = cast
}
}
propertyStr = propertyStr.replacingOccurrences(of: varTypeCast, with: castString)

let lowerCaseType = property.type.lowercased()
propertyStr = propertyStr.replacingOccurrences(of: lowerCaseVarType, with: lowerCaseType)

Expand Down