Kan1aSorata 2 years ago
parent
commit
4f4f40bbb9
53 changed files with 3259 additions and 351 deletions
  1. 54 3
      AIPaint.xcodeproj/project.pbxproj
  2. 1 1
      AIPaint.xcodeproj/xcuserdata/fengyuhe.xcuserdatad/xcschemes/xcschememanagement.plist
  3. 6 0
      AIPaint.xcworkspace/contents.xcworkspacedata
  4. 10 42
      AIPaint.xcworkspace/xcuserdata/fengyuhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  5. 8 2
      AIPaint/AIPaint.xcdatamodeld/AIPaint.xcdatamodel/contents
  6. 2 19
      AIPaint/AppDelegate.swift
  7. BIN
      AIPaint/Assets.xcassets/404.imageset/404.jpeg
  8. 21 0
      AIPaint/Assets.xcassets/404.imageset/Contents.json
  9. 158 10
      AIPaint/DrawViewController.swift
  10. 63 1
      AIPaint/HomeViewController.swift
  11. 4 2
      AIPaint/Info.plist
  12. 23 0
      AIPaint/Model/struct/Generate.swift
  13. 20 0
      AIPaint/SettingsViewController.swift
  14. 99 0
      AIPaint/View/PaintingCell.swift
  15. 16 0
      AIPaint/extension.swift
  16. 15 0
      Painting+CoreDataClass.swift
  17. 25 0
      Painting+CoreDataProperties.swift
  18. 1 0
      Podfile
  19. 5 1
      Podfile.lock
  20. 5 1
      Pods/Manifest.lock
  21. 433 243
      Pods/Pods.xcodeproj/project.pbxproj
  22. 58 0
      Pods/Pods.xcodeproj/xcuserdata/fengyuhe.xcuserdatad/xcschemes/SwiftyJSON.xcscheme
  23. 7 0
      Pods/Pods.xcodeproj/xcuserdata/fengyuhe.xcuserdatad/xcschemes/xcschememanagement.plist
  24. 21 0
      Pods/SwiftyJSON/LICENSE
  25. 562 0
      Pods/SwiftyJSON/README.md
  26. 1401 0
      Pods/SwiftyJSON/Source/SwiftyJSON/SwiftyJSON.swift
  27. 25 0
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-acknowledgements.markdown
  28. 31 0
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-acknowledgements.plist
  29. 2 1
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Debug-input-files.xcfilelist
  30. 2 1
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Debug-output-files.xcfilelist
  31. 2 1
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Release-input-files.xcfilelist
  32. 2 1
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Release-output-files.xcfilelist
  33. 2 0
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks.sh
  34. 3 3
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests.debug.xcconfig
  35. 3 3
      Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests.release.xcconfig
  36. 25 0
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-acknowledgements.markdown
  37. 31 0
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-acknowledgements.plist
  38. 2 1
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Debug-input-files.xcfilelist
  39. 2 1
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Debug-output-files.xcfilelist
  40. 2 1
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Release-input-files.xcfilelist
  41. 2 1
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Release-output-files.xcfilelist
  42. 2 0
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks.sh
  43. 3 3
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint.debug.xcconfig
  44. 3 3
      Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint.release.xcconfig
  45. 3 3
      Pods/Target Support Files/Pods-AIPaintTests/Pods-AIPaintTests.debug.xcconfig
  46. 3 3
      Pods/Target Support Files/Pods-AIPaintTests/Pods-AIPaintTests.release.xcconfig
  47. 26 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON-Info.plist
  48. 5 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON-dummy.m
  49. 12 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch
  50. 16 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON-umbrella.h
  51. 13 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON.debug.xcconfig
  52. 6 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON.modulemap
  53. 13 0
      Pods/Target Support Files/SwiftyJSON/SwiftyJSON.release.xcconfig

+ 54 - 3
AIPaint.xcodeproj/project.pbxproj

@@ -21,6 +21,9 @@
 		FADEA4A42936108100F1743C /* DrawViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FADEA4A32936108100F1743C /* DrawViewController.swift */; };
 		FADEA4A62936131700F1743C /* HomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FADEA4A52936131700F1743C /* HomeViewController.swift */; };
 		FADEA4A82936132700F1743C /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FADEA4A72936132700F1743C /* SettingsViewController.swift */; };
+		FADEA4AF2936642900F1743C /* Generate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FADEA4AE2936642900F1743C /* Generate.swift */; };
+		FAEAEB692938ED5B00C1D1E6 /* PaintingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEAEB682938ED5B00C1D1E6 /* PaintingCell.swift */; };
+		FAEAEB6B293A2B7F00C1D1E6 /* extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEAEB6A293A2B7F00C1D1E6 /* extension.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -65,6 +68,9 @@
 		FADEA4A32936108100F1743C /* DrawViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawViewController.swift; sourceTree = "<group>"; };
 		FADEA4A52936131700F1743C /* HomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewController.swift; sourceTree = "<group>"; };
 		FADEA4A72936132700F1743C /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
+		FADEA4AE2936642900F1743C /* Generate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Generate.swift; sourceTree = "<group>"; };
+		FAEAEB682938ED5B00C1D1E6 /* PaintingCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaintingCell.swift; sourceTree = "<group>"; };
+		FAEAEB6A293A2B7F00C1D1E6 /* extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = extension.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -115,7 +121,6 @@
 				4FF64EC94FD620B6D86C5DEA /* Pods-AIPaintTests.debug.xcconfig */,
 				2296AF3D6C42E14C6421896D /* Pods-AIPaintTests.release.xcconfig */,
 			);
-			name = Pods;
 			path = Pods;
 			sourceTree = "<group>";
 		};
@@ -144,6 +149,8 @@
 		FADEA46F2936102A00F1743C /* AIPaint */ = {
 			isa = PBXGroup;
 			children = (
+				FAEAEB672938ED4700C1D1E6 /* View */,
+				FADEA4AC2936630700F1743C /* Model */,
 				FADEA4762936102A00F1743C /* Main.storyboard */,
 				FADEA47C2936102B00F1743C /* Assets.xcassets */,
 				FADEA47E2936102B00F1743C /* LaunchScreen.storyboard */,
@@ -153,6 +160,7 @@
 				FADEA4A32936108100F1743C /* DrawViewController.swift */,
 				FADEA4A52936131700F1743C /* HomeViewController.swift */,
 				FADEA4A72936132700F1743C /* SettingsViewController.swift */,
+				FAEAEB6A293A2B7F00C1D1E6 /* extension.swift */,
 			);
 			path = AIPaint;
 			sourceTree = "<group>";
@@ -174,6 +182,30 @@
 			path = AIPaintUITests;
 			sourceTree = "<group>";
 		};
+		FADEA4AC2936630700F1743C /* Model */ = {
+			isa = PBXGroup;
+			children = (
+				FADEA4AD2936636200F1743C /* struct */,
+			);
+			path = Model;
+			sourceTree = "<group>";
+		};
+		FADEA4AD2936636200F1743C /* struct */ = {
+			isa = PBXGroup;
+			children = (
+				FADEA4AE2936642900F1743C /* Generate.swift */,
+			);
+			path = struct;
+			sourceTree = "<group>";
+		};
+		FAEAEB672938ED4700C1D1E6 /* View */ = {
+			isa = PBXGroup;
+			children = (
+				FAEAEB682938ED5B00C1D1E6 /* PaintingCell.swift */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
@@ -415,9 +447,12 @@
 			files = (
 				FADEA4A42936108100F1743C /* DrawViewController.swift in Sources */,
 				FADEA4712936102A00F1743C /* AppDelegate.swift in Sources */,
+				FAEAEB692938ED5B00C1D1E6 /* PaintingCell.swift in Sources */,
+				FADEA4AF2936642900F1743C /* Generate.swift in Sources */,
 				FADEA47B2936102A00F1743C /* AIPaint.xcdatamodeld in Sources */,
 				FADEA4A82936132700F1743C /* SettingsViewController.swift in Sources */,
 				FADEA4A62936131700F1743C /* HomeViewController.swift in Sources */,
+				FAEAEB6B293A2B7F00C1D1E6 /* extension.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -523,7 +558,7 @@
 				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 16.1;
+				IPHONEOS_DEPLOYMENT_TARGET = 16.0;
 				MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
 				MTL_FAST_MATH = YES;
 				ONLY_ACTIVE_ARCH = YES;
@@ -577,7 +612,7 @@
 				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 16.1;
+				IPHONEOS_DEPLOYMENT_TARGET = 16.0;
 				MTL_ENABLE_DEBUG_INFO = NO;
 				MTL_FAST_MATH = YES;
 				SDKROOT = iphoneos;
@@ -608,6 +643,14 @@
 					"@executable_path/Frameworks",
 				);
 				MARKETING_VERSION = 1.0;
+				OTHER_LDFLAGS = (
+					"$(inherited)",
+					"-framework",
+					"\"SnapKit\"",
+					"-framework",
+					"\"SwiftyJSON\"",
+					"-ObjC",
+				);
 				PRODUCT_BUNDLE_IDENTIFIER = fengyuhe.AIPaint;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_EMIT_LOC_STRINGS = YES;
@@ -637,6 +680,14 @@
 					"@executable_path/Frameworks",
 				);
 				MARKETING_VERSION = 1.0;
+				OTHER_LDFLAGS = (
+					"$(inherited)",
+					"-framework",
+					"\"SnapKit\"",
+					"-framework",
+					"\"SwiftyJSON\"",
+					"-ObjC",
+				);
 				PRODUCT_BUNDLE_IDENTIFIER = fengyuhe.AIPaint;
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_EMIT_LOC_STRINGS = YES;

+ 1 - 1
AIPaint.xcodeproj/xcuserdata/fengyuhe.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -7,7 +7,7 @@
 		<key>AIPaint.xcscheme_^#shared#^_</key>
 		<dict>
 			<key>orderHint</key>
-			<integer>4</integer>
+			<integer>5</integer>
 		</dict>
 	</dict>
 </dict>

+ 6 - 0
AIPaint.xcworkspace/contents.xcworkspacedata

@@ -1,6 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Workspace
    version = "1.0">
+   <FileRef
+      location = "group:Painting+CoreDataClass.swift">
+   </FileRef>
+   <FileRef
+      location = "group:Painting+CoreDataProperties.swift">
+   </FileRef>
    <FileRef
       location = "group:AIPaint.xcodeproj">
    </FileRef>

+ 10 - 42
AIPaint.xcworkspace/xcuserdata/fengyuhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -7,64 +7,32 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "BD62A08A-FA56-4199-8CD8-CE29AB713F26"
+            uuid = "1D14C76E-0689-48E8-A564-AAAA1146E5BE"
             shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "AIPaint/DrawViewController.swift"
+            filePath = "AIPaint/HomeViewController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "116"
-            endingLineNumber = "116"
-            landmarkName = "generateAction()"
+            startingLineNumber = "37"
+            endingLineNumber = "37"
+            landmarkName = "viewDidLoad()"
             landmarkType = "7">
-            <Locations>
-               <Location
-                  uuid = "BD62A08A-FA56-4199-8CD8-CE29AB713F26 - ed60bc0a5a2fad89"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "AIPaint.DrawViewController.generateAction() -&gt; ()"
-                  moduleName = "AIPaint"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/fengyuhe/Library/Mobile%20Documents/com~apple~CloudDocs/Code/Swift/Apps/AIPaint/AIPaint/DrawViewController.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "127"
-                  endingLineNumber = "127"
-                  offsetFromSymbolStart = "3603">
-               </Location>
-               <Location
-                  uuid = "BD62A08A-FA56-4199-8CD8-CE29AB713F26 - 278b956daa2cd23a"
-                  shouldBeEnabled = "Yes"
-                  ignoreCount = "0"
-                  continueAfterRunningActions = "No"
-                  symbolName = "closure #1 @Sendable (Swift.Optional&lt;Foundation.Data&gt;, Swift.Optional&lt;__C.NSURLResponse&gt;, Swift.Optional&lt;Swift.Error&gt;) -&gt; () in AIPaint.DrawViewController.generateAction() -&gt; ()"
-                  moduleName = "AIPaint"
-                  usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/fengyuhe/Library/Mobile%20Documents/com~apple~CloudDocs/Code/Swift/Apps/AIPaint/AIPaint/DrawViewController.swift"
-                  startingColumnNumber = "9223372036854775807"
-                  endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "129"
-                  endingLineNumber = "129"
-                  offsetFromSymbolStart = "154">
-               </Location>
-            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "37A2F56C-AE03-491E-9BE4-B74FA7A62857"
+            uuid = "1049053F-4A7A-4B32-A9C6-05C87808A547"
             shouldBeEnabled = "No"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "AIPaint/DrawViewController.swift"
+            filePath = "AIPaint/HomeViewController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "117"
-            endingLineNumber = "117"
-            landmarkName = "generateAction()"
+            startingLineNumber = "36"
+            endingLineNumber = "36"
+            landmarkName = "viewDidLoad()"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>

+ 8 - 2
AIPaint/AIPaint.xcdatamodeld/AIPaint.xcdatamodel/contents

@@ -1,4 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
-    <elements/>
+<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21512" systemVersion="22A380" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
+    <entity name="Painting" representedClassName="Painting" syncable="YES" codeGenerationType="class">
+        <attribute name="create_time" optional="YES" attributeType="Date" usesScalarValueType="NO"/>
+        <attribute name="image" optional="YES" attributeType="Binary"/>
+        <attribute name="negative_prompt" optional="YES" attributeType="String"/>
+        <attribute name="prompt" optional="YES" attributeType="String"/>
+        <attribute name="session_hash" optional="YES" attributeType="String"/>
+    </entity>
 </model>

+ 2 - 19
AIPaint/AppDelegate.swift

@@ -43,31 +43,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     // MARK: - Core Data stack
 
     lazy var persistentContainer: NSPersistentContainer = {
-        /*
-         The persistent container for the application. This implementation
-         creates and returns a container, having loaded the store for the
-         application to it. This property is optional since there are legitimate
-         error conditions that could cause the creation of the store to fail.
-        */
         let container = NSPersistentContainer(name: "AIPaint")
         container.loadPersistentStores(completionHandler: { (storeDescription, error) in
             if let error = error as NSError? {
-                // Replace this implementation with code to handle the error appropriately.
-                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
-                 
-                /*
-                 Typical reasons for an error here include:
-                 * The parent directory does not exist, cannot be created, or disallows writing.
-                 * The persistent store is not accessible, due to permissions or data protection when the device is locked.
-                 * The device is out of space.
-                 * The store could not be migrated to the current model version.
-                 Check the error message to determine what the actual problem was.
-                 */
                 fatalError("Unresolved error \(error), \(error.userInfo)")
             }
+            print("Load stores success")
         })
         return container
     }()
+    
 
     // MARK: - Core Data Saving support
 
@@ -77,8 +62,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             do {
                 try context.save()
             } catch {
-                // Replace this implementation with code to handle the error appropriately.
-                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                 let nserror = error as NSError
                 fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
             }

BIN
AIPaint/Assets.xcassets/404.imageset/404.jpeg


+ 21 - 0
AIPaint/Assets.xcassets/404.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "404.jpeg",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 158 - 10
AIPaint/DrawViewController.swift

@@ -6,7 +6,11 @@
 //
 
 import UIKit
+import Photos
 import SnapKit
+import SwiftyJSON
+import SwiftUI
+import CoreData
 
 class DrawViewController: UIViewController {
     
@@ -39,30 +43,48 @@ class DrawViewController: UIViewController {
         button.layer.backgroundColor = UIColor.blue.cgColor
         button.addTarget(self, action: #selector(generateAction), for: .touchUpInside)
         button.setTitle("生成图片", for: .normal)
+        button.isUserInteractionEnabled = true
         return button
     }()
     
+    var longPress: UILongPressGestureRecognizer?
+    
     lazy var generateImage: UIImageView = {
         let imageView = UIImageView()
         imageView.layer.borderWidth = 1
         imageView.layer.borderColor = UIColor.black.cgColor
+        imageView.isUserInteractionEnabled = true
         return imageView
     }()
     
     var prompt = ""
+    var tranPrompt = ""
     var negativePrompt = ""
+    var tranNegativePrompt = ""
+    var sessionHash = ""
+    var delegate: AppDelegate?
+    var context: NSManagedObjectContext?
+    var painting: Painting?
+    let alertController = UIAlertController(title: "保存成功!", message: nil, preferredStyle: .alert)
     
     override func viewDidLoad() {
         super.viewDidLoad()
         
         view.backgroundColor = .white
+        self.title = "AI Paint"
         
+        delegate = UIApplication.shared.delegate as? AppDelegate
+        context = delegate!.persistentContainer.viewContext
+        painting = NSEntityDescription.insertNewObject(forEntityName: "Painting", into: context!) as? Painting
+
         view.addSubview(generateView)
         generateView.addSubview(promptTextField)
         generateView.addSubview(negativePromptTextField)
         generateView.addSubview(generateButton)
         
         view.addSubview(generateImage)
+        longPress = UILongPressGestureRecognizer(target: self, action: #selector(saveImageToPhotos))
+        generateImage.addGestureRecognizer(longPress!)
         
         generateView.snp.makeConstraints { (make) in
             make.top.equalTo(view.safeAreaLayoutGuide.snp.top)
@@ -98,31 +120,157 @@ class DrawViewController: UIViewController {
             make.height.equalTo(view.safeAreaLayoutGuide.snp.height).multipliedBy(0.60)
             make.centerX.equalTo(view.safeAreaLayoutGuide.snp.centerX)
         }
+    }
+    
+    func translatePrompt(prompt: String, negativePrompt: String) -> (tranPrompt: String, tranNegativePrompt: String){
+        let APP_KEY = "3bb96f14d2af67ec"
+        let APP_SECRET = "SRQF1jGwAMuYciFK33KfyRGKa7B1x38u"
+        let q = prompt + "|" + negativePrompt
+        let salt = UUID().uuidString
+        let curtime = Int(Date().timeIntervalSince1970)
+        print(curtime)
+        let signStr = APP_KEY + q + salt + String(curtime) + APP_SECRET
+        let cryptoSign = signStr.sha256
+        let paramDic = ["q": q, "from": "auto", "to": "en", "appKey": APP_KEY, "salt": salt, "sign": cryptoSign, "signType": "v3", "curtime": String(curtime)]
+        let list  = NSMutableArray()
+        for subDic in paramDic {
+            let tmpStr = "\(subDic.0)=\(subDic.1)"
+            list.add(tmpStr)
+        }
+        let paramStr = list.componentsJoined(by: "&")
+        let paramData = "https://openapi.youdao.com/api?" + paramStr
+        var addr = paramData.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
+        let url = URL(string: addr!)
+        var request = URLRequest(url: url!)
+        request.httpMethod = "GET"
+        
+        var promptValue = ""
+        var negativePromotValue = ""
         
+        let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
+            do {
+                let jsonData = try JSON(data: data!)
+                let promptData = jsonData["translation"][0].stringValue
+                print(promptData)
+                if String(promptData.first!) == "|" {
+                    let subStringArr = promptData.split(separator: "| ")
+                    negativePromotValue = String(subStringArr[0])
+                    
+                } else if String(promptData.last!) == "|" {
+                    let subStringArr = promptData.split(separator: " |")
+                    promptValue = String(subStringArr[0])
+                } else {
+                    let subStringArr = promptData.split(separator: " | ")
+                    promptValue = String(subStringArr[0])
+                    negativePromotValue = String(subStringArr[1])
+                }
+            } catch {}
+        }
+        task.resume()
+        return (promptValue, negativePromotValue)
     }
     
     @objc func generateAction() {
-        print("in func generateAction")
-        prompt = promptTextField.text!
-        negativePrompt = negativePromptTextField.text!
+        let translation = translatePrompt(prompt: promptTextField.text!, negativePrompt: negativePromptTextField.text!)
+        generateButton.backgroundColor = .gray
+        generateButton.isUserInteractionEnabled = false
+        
+        print("translation", translation)
+        var promptValue = translation.tranPrompt
+        var negativePromotValue = translation.tranNegativePrompt
         
+        print("Generation: \(promptValue) + \(negativePromotValue)")
+        
+        prompt = "masterpiece, best quality, " + promptValue
+        negativePrompt = "lowres, bad anatomy, bad hands, text, error, missing fingers, extra digits, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, " + negativePromotValue
+        sessionHash = UUID().uuidString
+        painting?.prompt = promptTextField.text!
+        painting?.negative_prompt = negativePromptTextField.text!
+        painting?.session_hash = sessionHash
+        painting?.create_time = Date()
         let url = URL(string: "https://aipaint.hefengyu.org/api/predict/")
         var request = URLRequest(url: url!)
         request.httpMethod = "POST"
-        let postData: [String: Any] = ["fn_index":50,"data":["backed","shit","None","None",20,"Euler a",false,false,1,1,7,-1,-1,0,0,0,false,512,512,false,0.7,0,0,"None",false,false,false,"","Seed","","Nothing","",true,false,false,"null","",""]]
+        let postData: [String: Any] = ["fn_index":50,"data":[prompt,negativePrompt,"None","None",20,"Euler a",false,false,1,1,7,-1,-1,0,0,0,false,512,512,false,0.7,0,0,"None",false,false,false,"","Seed","","Nothing","",true,false,false,"null","",""],"session_hash":sessionHash]
         let jsonData = try? JSONSerialization.data(withJSONObject: postData, options: [])
+        request.setValue("application/json", forHTTPHeaderField: "Content-Type")
         request.httpBody = jsonData
-        print(String(data: jsonData!, encoding: .utf8)!)
+        var imageData: Data?
         let dataTask = URLSession.shared.dataTask(with: request) { (data, request, error) in
             do {
-                let jsonData = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as! NSDictionary
-                print(jsonData)
-            } catch {
-                print("JSONSerialization error:", error)
+                let json = try? JSON(data: data!)
+                let imageAddr = json!["data"][0][0]["name"].stringValue
+                let addrProcess = imageAddr.replacingOccurrences(of: "\\", with: "/")
+                let imageStr = "https://aipaint.hefengyu.org/file=\(addrProcess)"
+                let imageUrl = URL(string: imageStr)
+                imageData = try? Data(contentsOf: imageUrl!)
+                DispatchQueue.main.async { [self] in
+                    painting?.image = imageData!
+                    self.generateImage.image = UIImage(data: imageData!)
+                    self.generateButton.backgroundColor = .blue
+                    self.generateButton.isUserInteractionEnabled = true
+                    if context!.hasChanges {
+                        do {
+                            try context?.save()
+                            print("save success.")
+                        } catch {}
+                    }
+                }
             }
         }
+//        let processURL = URL(string: "https://aipaint.hefengyu.org/api/predict/")
+//        let processTask = URLSession.shared.dataTask(with: <#T##URLRequest#>)
         dataTask.resume()
-        
+    }
+    
+    @objc func saveImageToPhotos() {
+        if (longPress!.state == .began) {
+            // do something
+            print("nice")
+            guard let img = generateImage.image else {
+                return
+            }
+            
+            switch PHPhotoLibrary.authorizationStatus() {
+            case .authorized:
+                saveImg(image: img)
+            case .notDetermined:
+                PHPhotoLibrary.requestAuthorization { (status) in
+                    if status == .authorized {
+                        self.saveImg(image: img)
+                    } else {
+                        print("用户拒绝访问")
+                    }
+                }
+            case .restricted, .denied:
+                if let url = URL.init(string: UIApplication.openSettingsURLString) {
+                    if UIApplication.shared.canOpenURL(url) {
+                        UIApplication.shared.open(url)
+                    }
+                }
+            case .limited:
+                return
+            @unknown default:
+                return
+            }
+        }else if (longPress!.state == .ended){
+            return
+        }
+    }
+    
+    func saveImg(image: UIImage) {
+        PHPhotoLibrary.shared().performChanges({
+            PHAssetChangeRequest.creationRequestForAsset(from: image)
+        }, completionHandler: { (isSuccess, error) in
+            DispatchQueue.main.async {
+                if isSuccess{
+                    self.present(self.alertController, animated: true, completion: nil)
+                    DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2) {
+                        self.alertController.dismiss(animated: false)
+                    }
+                }
+            }
+        })
     }
     
     override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

+ 63 - 1
AIPaint/HomeViewController.swift

@@ -6,11 +6,73 @@
 //
 
 import UIKit
+import SnapKit
+import CoreData
 
-class HomeViewController: UIViewController {
+class HomeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
+    
+    lazy var paintingTableView: UITableView = {
+        let tableView = UITableView()
+        tableView.separatorStyle = .singleLine
+        tableView.separatorInset = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
+        tableView.allowsSelection = true
+        tableView.allowsMultipleSelection = false
+        return tableView
+    }()
+
+    var delegate: AppDelegate?
+    var context: NSManagedObjectContext?
+    var painting: Painting?
+    var fetchPainting: NSFetchRequest<Painting>?
+    var info: [Painting] = []
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         
         view.backgroundColor = .white
+        self.title = "作品"
+        
+        delegate = UIApplication.shared.delegate as? AppDelegate
+        context = delegate!.persistentContainer.viewContext
+        fetchPainting = NSFetchRequest<Painting>.init(entityName: "Painting")
+        
+        paintingTableView.delegate = self
+        paintingTableView.dataSource = self
+//        paintingTableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell")
+        view.addSubview(paintingTableView)
+        
+        paintingTableView.snp.makeConstraints { (make) in
+            make.top.equalTo(view.safeAreaLayoutGuide.snp.top)
+            make.width.equalTo(view.safeAreaLayoutGuide.snp.width)
+            make.height.equalTo(view.safeAreaLayoutGuide.snp.height)
+            make.centerX.equalTo(view.safeAreaLayoutGuide.snp.centerX)
+        }
+        
+        do {
+            let paintings = try context?.fetch(fetchPainting!)
+            for painting in paintings! {
+                info.append(painting)
+            }
+        } catch {}
+        
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+
+        paintingTableView.reloadData()
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return info.count
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        let cell = PaintingCell(style: .default, reuseIdentifier: "PaintingCell")
+        cell.setValueForCell(painting: info[indexPath.row])
+        return cell
+    }
+    
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return 100
     }
 }

+ 4 - 2
AIPaint/Info.plist

@@ -2,7 +2,9 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key></key>
-	<string></string>
+	<key>NSPhotoLibraryUsageDescription</key>
+	<string>Access your photo library to save pictures.</string>
+	<key>NSPhotoLibraryAddUsageDescription</key>
+	<string>Access your photo library to save pictures.</string>
 </dict>
 </plist>

+ 23 - 0
AIPaint/Model/struct/Generate.swift

@@ -0,0 +1,23 @@
+//
+//  Generate.swift
+//  AIPaint
+//
+//  Created by Fengyu He on 2022/11/30.
+//
+
+import Foundation
+
+struct Generate {
+    var data: [[Any]]
+    var isGenerating: Bool
+    var duration: Double
+    var averageDuration: Double
+}
+
+extension Generate {
+    struct Info: Codable {
+        var name: String
+        var data: String
+        var isFile: Bool
+    }
+}

+ 20 - 0
AIPaint/SettingsViewController.swift

@@ -6,11 +6,31 @@
 //
 
 import UIKit
+import SnapKit
 
 class SettingsViewController: UIViewController {
+    
+    let welcomeView: UIView = {
+        var view = UIView()
+        view.layer.borderWidth = 1
+        view.layer.borderColor = UIColor.black.cgColor
+        view.layer.cornerRadius = 14
+        return view
+    }()
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         
         view.backgroundColor = .white
+        self.title = "设置"
+        
+        view.addSubview(welcomeView)
+        
+        welcomeView.snp.makeConstraints { (make) in
+            make.top.equalTo(view.safeAreaLayoutGuide.snp.top).offset(5)
+            make.centerX.equalTo(view.safeAreaLayoutGuide.snp.centerX)
+            make.width.equalTo(view.safeAreaLayoutGuide.snp.width).multipliedBy(0.95)
+            make.height.equalTo(view.safeAreaLayoutGuide.snp.height)
+        }
     }
 }

+ 99 - 0
AIPaint/View/PaintingCell.swift

@@ -0,0 +1,99 @@
+//
+//  PaintingCell.swift
+//  AIPaint
+//
+//  Created by Fengyu He on 2022/12/1.
+//
+
+import UIKit
+import SnapKit
+
+class PaintingCell: UITableViewCell {
+    var paintingView: UIImageView?
+    var createTime: UILabel?
+    var sessionHash: UILabel?
+    var prompt: UILabel?
+    var negativePrompt: UILabel?
+    
+    required init?(coder: NSCoder) {
+        super.init(coder: coder)
+    }
+    
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        setUpUI()
+    }
+    
+    func setUpUI() {
+        paintingView = UIImageView()
+        
+        createTime = {
+            var label = UILabel()
+            label.font = UIFont.systemFont(ofSize: 15)
+            label.textAlignment = .left
+            label.textColor = .black
+            return label
+        }()
+        
+        sessionHash = {
+            var label = UILabel()
+            label.font = UIFont.systemFont(ofSize: 15)
+            label.textAlignment = .left
+            label.textColor = .black
+            return label
+        }()
+        
+        prompt = {
+            var label = UILabel()
+            label.font = UIFont.systemFont(ofSize: 15)
+            label.textAlignment = .left
+            label.textColor = .black
+            return label
+        }()
+        
+        negativePrompt = {
+            var label = UILabel()
+            label.font = UIFont.systemFont(ofSize: 15)
+            label.textAlignment = .left
+            label.textColor = .black
+            return label
+        }()
+        
+        self.addSubview(paintingView!)
+        self.addSubview(createTime!)
+        self.addSubview(sessionHash!)
+        self.addSubview(prompt!)
+        self.addSubview(negativePrompt!)
+        
+        paintingView!.snp.makeConstraints { (make) in
+            make.centerY.equalTo(self.snp.centerY)
+            make.left.equalTo(self.snp.left).offset(5)
+            make.height.equalTo(self.snp.height).multipliedBy(0.9)
+            make.width.equalTo(self.snp.height).multipliedBy(0.9)
+        }
+        
+        prompt!.snp.makeConstraints { (make) in
+            make.top.equalTo(self.snp.top).offset(5)
+            make.left.equalTo(paintingView!.snp.right).offset(5)
+            make.height.equalTo(self.snp.height).multipliedBy(0.2)
+            make.right.equalTo(self.snp.right).offset(-5)
+        }
+        
+        sessionHash!.snp.makeConstraints { (make) in
+            make.top.equalTo(prompt!.snp.bottom).offset(5)
+            make.left.equalTo(paintingView!.snp.right).offset(5)
+            make.height.equalTo(self.snp.height).multipliedBy(0.2)
+            make.right.equalTo(self.snp.right).offset(-5)
+        }
+    }
+    
+    func setValueForCell(painting: Painting) {
+        if painting.image == nil {
+            paintingView?.image = UIImage(named: "404.jpeg")
+        } else {
+            paintingView?.image = UIImage(data: painting.image!)
+        }
+        prompt?.text = painting.prompt
+        sessionHash?.text = painting.session_hash
+    }
+}

+ 16 - 0
AIPaint/extension.swift

@@ -0,0 +1,16 @@
+//
+//  extension.swift
+//  AIPaint
+//
+//  Created by Fengyu He on 2022/12/2.
+//
+import CommonCrypto
+
+extension String {
+    var sha256: String {
+        let utf8 = cString(using: .utf8)
+        var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
+        CC_SHA256(utf8, CC_LONG(utf8!.count - 1), &digest)
+        return digest.reduce("") { $0 + String(format:"%02x", $1) }
+    }
+}

+ 15 - 0
Painting+CoreDataClass.swift

@@ -0,0 +1,15 @@
+//
+//  Painting+CoreDataClass.swift
+//  
+//
+//  Created by Fengyu He on 2022/12/1.
+//
+//
+
+import Foundation
+import CoreData
+
+@objc(Painting)
+public class Painting: NSManagedObject {
+
+}

+ 25 - 0
Painting+CoreDataProperties.swift

@@ -0,0 +1,25 @@
+//
+//  Painting+CoreDataProperties.swift
+//  
+//
+//  Created by Fengyu He on 2022/12/1.
+//
+//
+
+import Foundation
+import CoreData
+
+
+extension Painting {
+
+    @nonobjc public class func fetchRequest() -> NSFetchRequest<Painting> {
+        return NSFetchRequest<Painting>(entityName: "Painting")
+    }
+
+    @NSManaged public var create_time: Date?
+    @NSManaged public var image: Data?
+    @NSManaged public var session_hash: String?
+    @NSManaged public var prompt: String?
+    @NSManaged public var negative_prompt: String?
+
+}

+ 1 - 0
Podfile

@@ -5,6 +5,7 @@ target 'AIPaint' do
   # Comment the next line if you don't want to use dynamic frameworks
   use_frameworks!
   pod 'SnapKit', '~> 5.6.0'
+pod 'SwiftyJSON', '~> 4.0'
   # Pods for AIPaint
 
   target 'AIPaintTests' do

+ 5 - 1
Podfile.lock

@@ -1,16 +1,20 @@
 PODS:
   - SnapKit (5.6.0)
+  - SwiftyJSON (4.3.0)
 
 DEPENDENCIES:
   - SnapKit (~> 5.6.0)
+  - SwiftyJSON (~> 4.0)
 
 SPEC REPOS:
   trunk:
     - SnapKit
+    - SwiftyJSON
 
 SPEC CHECKSUMS:
   SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
+  SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08
 
-PODFILE CHECKSUM: 704a944f5469348aebbecd1281fa0eddc9378527
+PODFILE CHECKSUM: 5826ad7619bdb46788253a6e42cd1a78be23d357
 
 COCOAPODS: 1.11.3

+ 5 - 1
Pods/Manifest.lock

@@ -1,16 +1,20 @@
 PODS:
   - SnapKit (5.6.0)
+  - SwiftyJSON (4.3.0)
 
 DEPENDENCIES:
   - SnapKit (~> 5.6.0)
+  - SwiftyJSON (~> 4.0)
 
 SPEC REPOS:
   trunk:
     - SnapKit
+    - SwiftyJSON
 
 SPEC CHECKSUMS:
   SnapKit: e01d52ebb8ddbc333eefe2132acf85c8227d9c25
+  SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08
 
-PODFILE CHECKSUM: 704a944f5469348aebbecd1281fa0eddc9378527
+PODFILE CHECKSUM: 5826ad7619bdb46788253a6e42cd1a78be23d357
 
 COCOAPODS: 1.11.3

File diff suppressed because it is too large
+ 433 - 243
Pods/Pods.xcodeproj/project.pbxproj


+ 58 - 0
Pods/Pods.xcodeproj/xcuserdata/fengyuhe.xcuserdatad/xcschemes/SwiftyJSON.xcscheme

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "1300"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "D118A6A04828FD3CDA8640CD2B6796D2"
+               BuildableName = "SwiftyJSON.framework"
+               BlueprintName = "SwiftyJSON"
+               ReferencedContainer = "container:Pods.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 7 - 0
Pods/Pods.xcodeproj/xcuserdata/fengyuhe.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -32,6 +32,13 @@
 			<key>orderHint</key>
 			<integer>3</integer>
 		</dict>
+		<key>SwiftyJSON.xcscheme</key>
+		<dict>
+			<key>isShown</key>
+			<false/>
+			<key>orderHint</key>
+			<integer>4</integer>
+		</dict>
 	</dict>
 	<key>SuppressBuildableAutocreation</key>
 	<dict/>

+ 21 - 0
Pods/SwiftyJSON/LICENSE

@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 Ruoyu Fu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

+ 562 - 0
Pods/SwiftyJSON/README.md

@@ -0,0 +1,562 @@
+# SwiftyJSON
+
+[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![CocoaPods](https://img.shields.io/cocoapods/v/SwiftyJSON.svg) ![Platform](https://img.shields.io/badge/platforms-iOS%208.0%20%7C%20macOS%2010.10%20%7C%20tvOS%209.0%20%7C%20watchOS%203.0-F28D00.svg) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
+
+SwiftyJSON makes it easy to deal with JSON data in Swift.
+
+Platform | Build Status
+---------| --------------| 
+*OS      | [![Travis CI](https://travis-ci.org/SwiftyJSON/SwiftyJSON.svg?branch=master)](https://travis-ci.org/SwiftyJSON/SwiftyJSON)    | 
+[Linux](https://github.com/IBM-Swift/SwiftyJSON)      | [![Build Status](https://travis-ci.org/IBM-Swift/SwiftyJSON.svg?branch=master)](https://travis-ci.org/IBM-Swift/SwiftyJSON)     | 
+
+
+1. [Why is the typical JSON handling in Swift NOT good](#why-is-the-typical-json-handling-in-swift-not-good)
+2. [Requirements](#requirements)
+3. [Integration](#integration)
+4. [Usage](#usage)
+   - [Initialization](#initialization)
+   - [Subscript](#subscript)
+   - [Loop](#loop)
+   - [Error](#error)
+   - [Optional getter](#optional-getter)
+   - [Non-optional getter](#non-optional-getter)
+   - [Setter](#setter)
+   - [Raw object](#raw-object)
+   - [Literal convertibles](#literal-convertibles)
+   - [Merging](#merging)
+5. [Work with Alamofire](#work-with-alamofire)
+6. [Work with Moya](#work-with-moya)
+7. [SwiftyJSON Model Generator](#swiftyjson-model-generator)
+
+> [中文介绍](http://tangplin.github.io/swiftyjson/)
+
+
+## Why is the typical JSON handling in Swift NOT good?
+
+Swift is very strict about types. But although explicit typing is good for saving us from mistakes, it becomes painful when dealing with JSON and other areas that are, by nature, implicit about types.
+
+Take the Twitter API for example. Say we want to retrieve a user's "name" value of some tweet in Swift (according to [Twitter's API](https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline)).
+
+The code would look like this:
+
+```swift
+if let statusesArray = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]],
+    let user = statusesArray[0]["user"] as? [String: Any],
+    let username = user["name"] as? String {
+    // Finally we got the username
+}
+```
+
+It's not good.
+
+Even if we use optional chaining, it would be messy:
+
+```swift
+if let JSONObject = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? [[String: Any]],
+    let username = (JSONObject[0]["user"] as? [String: Any])?["name"] as? String {
+        // There's our username
+}
+```
+
+An unreadable mess--for something that should really be simple!
+
+With SwiftyJSON all you have to do is:
+
+```swift
+let json = JSON(data: dataFromNetworking)
+if let userName = json[0]["user"]["name"].string {
+  //Now you got your value
+}
+```
+
+And don't worry about the Optional Wrapping thing. It's done for you automatically.
+
+```swift
+let json = JSON(data: dataFromNetworking)
+let result = json[999999]["wrong_key"]["wrong_name"]
+if let userName = result.string {
+    //Calm down, take it easy, the ".string" property still produces the correct Optional String type with safety
+} else {
+    //Print the error
+    print(result.error)
+}
+```
+
+## Requirements
+
+- iOS 8.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+
+- Xcode 8
+
+## Integration
+
+#### CocoaPods (iOS 8+, OS X 10.9+)
+
+You can use [CocoaPods](http://cocoapods.org/) to install `SwiftyJSON` by adding it to your `Podfile`:
+
+```ruby
+platform :ios, '8.0'
+use_frameworks!
+
+target 'MyApp' do
+    pod 'SwiftyJSON', '~> 4.0'
+end
+```
+
+#### Carthage (iOS 8+, OS X 10.9+)
+
+You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftyJSON` by adding it to your `Cartfile`:
+
+```
+github "SwiftyJSON/SwiftyJSON" ~> 4.0
+```
+
+If you use Carthage to build your dependencies, make sure you have added `SwiftyJSON.framework` to the "Linked Frameworks and Libraries" section of your target, and have included them in your Carthage framework copying build phase.
+
+#### Swift Package Manager
+
+You can use [The Swift Package Manager](https://swift.org/package-manager) to install `SwiftyJSON` by adding the proper description to your `Package.swift` file:
+
+```swift
+// swift-tools-version:4.0
+import PackageDescription
+
+let package = Package(
+    name: "YOUR_PROJECT_NAME",
+    dependencies: [
+        .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"),
+    ]
+)
+```
+Then run `swift build` whenever you get prepared.
+
+#### Manually (iOS 7+, OS X 10.9+)
+
+To use this library in your project manually you may:  
+
+1. for Projects, just drag SwiftyJSON.swift to the project tree
+2. for Workspaces, include the whole SwiftyJSON.xcodeproj
+
+## Usage
+
+#### Initialization
+
+```swift
+import SwiftyJSON
+```
+
+```swift
+let json = JSON(data: dataFromNetworking)
+```
+Or
+
+```swift
+let json = JSON(jsonObject)
+```
+Or
+
+```swift
+if let dataFromString = jsonString.data(using: .utf8, allowLossyConversion: false) {
+    let json = JSON(data: dataFromString)
+}
+```
+
+#### Subscript
+
+```swift
+// Getting a double from a JSON Array
+let name = json[0].double
+```
+
+```swift
+// Getting an array of string from a JSON Array
+let arrayNames =  json["users"].arrayValue.map {$0["name"].stringValue}
+```
+
+```swift
+// Getting a string from a JSON Dictionary
+let name = json["name"].stringValue
+```
+
+```swift
+// Getting a string using a path to the element
+let path: [JSONSubscriptType] = [1,"list",2,"name"]
+let name = json[path].string
+// Just the same
+let name = json[1]["list"][2]["name"].string
+// Alternatively
+let name = json[1,"list",2,"name"].string
+```
+
+```swift
+// With a hard way
+let name = json[].string
+```
+
+```swift
+// With a custom way
+let keys:[JSONSubscriptType] = [1,"list",2,"name"]
+let name = json[keys].string
+```
+
+#### Loop
+
+```swift
+// If json is .Dictionary
+for (key,subJson):(String, JSON) in json {
+   // Do something you want
+}
+```
+
+*The first element is always a String, even if the JSON is an Array*
+
+```swift
+// If json is .Array
+// The `index` is 0..<json.count's string value
+for (index,subJson):(String, JSON) in json {
+    // Do something you want
+}
+```
+
+#### Error
+
+##### SwiftyJSON 4.x
+
+SwiftyJSON 4.x introduces an enum type called `SwiftyJSONError`, which includes `unsupportedType`, `indexOutOfBounds`, `elementTooDeep`, `wrongType`, `notExist` and `invalidJSON`, at the same time, `ErrorDomain` are being replaced by `SwiftyJSONError.errorDomain`.
+Note: Those old error types are deprecated in SwiftyJSON 4.x and will be removed in the future release.
+
+##### SwiftyJSON 3.x
+
+Use a subscript to get/set a value in an Array or Dictionary
+
+If the JSON is:
+*  an array, the app may crash with "index out-of-bounds."
+*  a dictionary, it will be assigned to `nil` without a reason.
+*  not an array or a dictionary, the app may crash with an "unrecognised selector" exception.
+
+This will never happen in SwiftyJSON.
+
+```swift
+let json = JSON(["name", "age"])
+if let name = json[999].string {
+    // Do something you want
+} else {
+    print(json[999].error!) // "Array[999] is out of bounds"
+}
+```
+
+```swift
+let json = JSON(["name":"Jack", "age": 25])
+if let name = json["address"].string {
+    // Do something you want
+} else {
+    print(json["address"].error!) // "Dictionary["address"] does not exist"
+}
+```
+
+```swift
+let json = JSON(12345)
+if let age = json[0].string {
+    // Do something you want
+} else {
+    print(json[0])       // "Array[0] failure, It is not an array"
+    print(json[0].error!) // "Array[0] failure, It is not an array"
+}
+
+if let name = json["name"].string {
+    // Do something you want
+} else {
+    print(json["name"])       // "Dictionary[\"name"] failure, It is not an dictionary"
+    print(json["name"].error!) // "Dictionary[\"name"] failure, It is not an dictionary"
+}
+```
+
+#### Optional getter
+
+```swift
+// NSNumber
+if let id = json["user"]["favourites_count"].number {
+   // Do something you want
+} else {
+   // Print the error
+   print(json["user"]["favourites_count"].error!)
+}
+```
+
+```swift
+// String
+if let id = json["user"]["name"].string {
+   // Do something you want
+} else {
+   // Print the error
+   print(json["user"]["name"].error!)
+}
+```
+
+```swift
+// Bool
+if let id = json["user"]["is_translator"].bool {
+   // Do something you want
+} else {
+   // Print the error
+   print(json["user"]["is_translator"].error!)
+}
+```
+
+```swift
+// Int
+if let id = json["user"]["id"].int {
+   // Do something you want
+} else {
+   // Print the error
+   print(json["user"]["id"].error!)
+}
+...
+```
+
+#### Non-optional getter
+
+Non-optional getter is named `xxxValue`
+
+```swift
+// If not a Number or nil, return 0
+let id: Int = json["id"].intValue
+```
+
+```swift
+// If not a String or nil, return ""
+let name: String = json["name"].stringValue
+```
+
+```swift
+// If not an Array or nil, return []
+let list: Array<JSON> = json["list"].arrayValue
+```
+
+```swift
+// If not a Dictionary or nil, return [:]
+let user: Dictionary<String, JSON> = json["user"].dictionaryValue
+```
+
+#### Setter
+
+```swift
+json["name"] = JSON("new-name")
+json[0] = JSON(1)
+```
+
+```swift
+json["id"].int =  1234567890
+json["coordinate"].double =  8766.766
+json["name"].string =  "Jack"
+json.arrayObject = [1,2,3,4]
+json.dictionaryObject = ["name":"Jack", "age":25]
+```
+
+#### Raw object
+
+```swift
+let rawObject: Any = json.object
+```
+
+```swift
+let rawValue: Any = json.rawValue
+```
+
+```swift
+//convert the JSON to raw NSData
+do {
+	let rawData = try json.rawData()
+  //Do something you want
+} catch {
+	print("Error \(error)")
+}
+```
+
+```swift
+//convert the JSON to a raw String
+if let rawString = json.rawString() {
+  //Do something you want
+} else {
+	print("json.rawString is nil")
+}
+```
+
+#### Existence
+
+```swift
+// shows you whether value specified in JSON or not
+if json["name"].exists()
+```
+
+#### Literal convertibles
+
+For more info about literal convertibles: [Swift Literal Convertibles](http://nshipster.com/swift-literal-convertible/)
+
+```swift
+// StringLiteralConvertible
+let json: JSON = "I'm a json"
+```
+
+```swift
+/ /IntegerLiteralConvertible
+let json: JSON =  12345
+```
+
+```swift
+// BooleanLiteralConvertible
+let json: JSON =  true
+```
+
+```swift
+// FloatLiteralConvertible
+let json: JSON =  2.8765
+```
+
+```swift
+// DictionaryLiteralConvertible
+let json: JSON =  ["I":"am", "a":"json"]
+```
+
+```swift
+// ArrayLiteralConvertible
+let json: JSON =  ["I", "am", "a", "json"]
+```
+
+```swift
+// With subscript in array
+var json: JSON =  [1,2,3]
+json[0] = 100
+json[1] = 200
+json[2] = 300
+json[999] = 300 // Don't worry, nothing will happen
+```
+
+```swift
+// With subscript in dictionary
+var json: JSON =  ["name": "Jack", "age": 25]
+json["name"] = "Mike"
+json["age"] = "25" // It's OK to set String
+json["address"] = "L.A." // Add the "address": "L.A." in json
+```
+
+```swift
+// Array & Dictionary
+var json: JSON =  ["name": "Jack", "age": 25, "list": ["a", "b", "c", ["what": "this"]]]
+json["list"][3]["what"] = "that"
+json["list",3,"what"] = "that"
+let path: [JSONSubscriptType] = ["list",3,"what"]
+json[path] = "that"
+```
+
+```swift
+// With other JSON objects
+let user: JSON = ["username" : "Steve", "password": "supersecurepassword"]
+let auth: JSON = [
+  "user": user.object, // use user.object instead of just user
+  "apikey": "supersecretapitoken"
+]
+```
+
+#### Merging
+
+It is possible to merge one JSON into another JSON. Merging a JSON into another JSON adds all non existing values to the original JSON which are only present in the `other` JSON.
+
+If both JSONs contain a value for the same key, _mostly_ this value gets overwritten in the original JSON, but there are two cases where it provides some special treatment:
+
+- In case of both values being a `JSON.Type.array` the values form the array found in the `other` JSON getting appended to the original JSON's array value.
+- In case of both values being a `JSON.Type.dictionary` both JSON-values are getting merged the same way the encapsulating JSON is merged.
+
+In case, where two fields in a JSON have a different types, the value will get always overwritten.
+
+There are two different fashions for merging: `merge` modifies the original JSON, whereas `merged` works non-destructively on a copy.
+
+```swift
+let original: JSON = [
+    "first_name": "John",
+    "age": 20,
+    "skills": ["Coding", "Reading"],
+    "address": [
+        "street": "Front St",
+        "zip": "12345",
+    ]
+]
+
+let update: JSON = [
+    "last_name": "Doe",
+    "age": 21,
+    "skills": ["Writing"],
+    "address": [
+        "zip": "12342",
+        "city": "New York City"
+    ]
+]
+
+let updated = original.merge(with: update)
+// [
+//     "first_name": "John",
+//     "last_name": "Doe",
+//     "age": 21,
+//     "skills": ["Coding", "Reading", "Writing"],
+//     "address": [
+//         "street": "Front St",
+//         "zip": "12342",
+//         "city": "New York City"
+//     ]
+// ]
+```
+
+## String representation
+There are two options available:
+- use the default Swift one
+- use a custom one that will handle optionals well and represent `nil` as `"null"`:
+```swift
+let dict = ["1":2, "2":"two", "3": nil] as [String: Any?]
+let json = JSON(dict)
+let representation = json.rawString(options: [.castNilToNSNull: true])
+// representation is "{\"1\":2,\"2\":\"two\",\"3\":null}", which represents {"1":2,"2":"two","3":null}
+```
+
+## Work with [Alamofire](https://github.com/Alamofire/Alamofire)
+
+SwiftyJSON nicely wraps the result of the Alamofire JSON response handler:
+
+```swift
+Alamofire.request(url, method: .get).validate().responseJSON { response in
+    switch response.result {
+    case .success(let value):
+        let json = JSON(value)
+        print("JSON: \(json)")
+    case .failure(let error):
+        print(error)
+    }
+}
+```
+
+We also provide an extension of Alamofire for serializing NSData to SwiftyJSON's JSON.
+
+See: [Alamofire-SwiftyJSON](https://github.com/SwiftyJSON/Alamofire-SwiftyJSON)
+
+
+## Work with [Moya](https://github.com/Moya/Moya)
+
+SwiftyJSON parse data to JSON:
+
+```swift
+let provider = MoyaProvider<Backend>()
+provider.request(.showProducts) { result in
+    switch result {
+    case let .success(moyaResponse):
+        let data = moyaResponse.data
+        let json = JSON(data: data) // convert network data to json
+        print(json)
+    case let .failure(error):
+        print("error: \(error)")
+    }
+}
+
+```
+
+## SwiftyJSON Model Generator
+Tools to generate SwiftyJSON Models
+* [JSON Cafe](http://www.jsoncafe.com/)
+* [JSON Export](https://github.com/Ahmed-Ali/JSONExport)

+ 1401 - 0
Pods/SwiftyJSON/Source/SwiftyJSON/SwiftyJSON.swift

@@ -0,0 +1,1401 @@
+//  SwiftyJSON.swift
+//
+//  Copyright (c) 2014 - 2017 Ruoyu Fu, Pinglin Tang
+//
+//  Permission is hereby granted, free of charge, to any person obtaining a copy
+//  of this software and associated documentation files (the "Software"), to deal
+//  in the Software without restriction, including without limitation the rights
+//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+//  copies of the Software, and to permit persons to whom the Software is
+//  furnished to do so, subject to the following conditions:
+//
+//  The above copyright notice and this permission notice shall be included in
+//  all copies or substantial portions of the Software.
+//
+//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+//  THE SOFTWARE.
+
+import Foundation
+
+// MARK: - Error
+// swiftlint:disable line_length
+public enum SwiftyJSONError: Int, Swift.Error {
+    case unsupportedType = 999
+    case indexOutOfBounds = 900
+    case elementTooDeep = 902
+    case wrongType = 901
+    case notExist = 500
+    case invalidJSON = 490
+}
+
+extension SwiftyJSONError: CustomNSError {
+
+    /// return the error domain of SwiftyJSONError
+    public static var errorDomain: String { return "com.swiftyjson.SwiftyJSON" }
+
+    /// return the error code of SwiftyJSONError
+    public var errorCode: Int { return self.rawValue }
+
+    /// return the userInfo of SwiftyJSONError
+    public var errorUserInfo: [String: Any] {
+        switch self {
+        case .unsupportedType:
+            return [NSLocalizedDescriptionKey: "It is an unsupported type."]
+        case .indexOutOfBounds:
+            return [NSLocalizedDescriptionKey: "Array Index is out of bounds."]
+        case .wrongType:
+            return [NSLocalizedDescriptionKey: "Couldn't merge, because the JSONs differ in type on top level."]
+        case .notExist:
+            return [NSLocalizedDescriptionKey: "Dictionary key does not exist."]
+        case .invalidJSON:
+            return [NSLocalizedDescriptionKey: "JSON is invalid."]
+        case .elementTooDeep:
+            return [NSLocalizedDescriptionKey: "Element too deep. Increase maxObjectDepth and make sure there is no reference loop."]
+        }
+    }
+}
+
+// MARK: - JSON Type
+
+/**
+JSON's type definitions.
+
+See http://www.json.org
+*/
+public enum Type: Int {
+	case number
+	case string
+	case bool
+	case array
+	case dictionary
+	case null
+	case unknown
+}
+
+// MARK: - JSON Base
+
+public struct JSON {
+
+	/**
+	 Creates a JSON using the data.
+	
+	 - parameter data: The NSData used to convert to json.Top level object in data is an NSArray or NSDictionary
+	 - parameter opt: The JSON serialization reading options. `[]` by default.
+	
+	 - returns: The created JSON
+	 */
+    public init(data: Data, options opt: JSONSerialization.ReadingOptions = []) throws {
+        let object: Any = try JSONSerialization.jsonObject(with: data, options: opt)
+        self.init(jsonObject: object)
+    }
+
+    /**
+	 Creates a JSON object
+	 - note: this does not parse a `String` into JSON, instead use `init(parseJSON: String)`
+	
+	 - parameter object: the object
+
+	 - returns: the created JSON object
+	 */
+    public init(_ object: Any) {
+        switch object {
+        case let object as Data:
+            do {
+                try self.init(data: object)
+            } catch {
+                self.init(jsonObject: NSNull())
+            }
+        default:
+            self.init(jsonObject: object)
+        }
+    }
+
+	/**
+	 Parses the JSON string into a JSON object
+	
+	 - parameter json: the JSON string
+	
+	 - returns: the created JSON object
+	*/
+	public init(parseJSON jsonString: String) {
+		if let data = jsonString.data(using: .utf8) {
+			self.init(data)
+		} else {
+			self.init(NSNull())
+		}
+	}
+
+	/**
+	 Creates a JSON using the object.
+	
+	 - parameter jsonObject:  The object must have the following properties: All objects are NSString/String, NSNumber/Int/Float/Double/Bool, NSArray/Array, NSDictionary/Dictionary, or NSNull; All dictionary keys are NSStrings/String; NSNumbers are not NaN or infinity.
+	
+	 - returns: The created JSON
+	 */
+    fileprivate init(jsonObject: Any) {
+        object = jsonObject
+    }
+
+	/**
+	 Merges another JSON into this JSON, whereas primitive values which are not present in this JSON are getting added,
+	 present values getting overwritten, array values getting appended and nested JSONs getting merged the same way.
+ 
+	 - parameter other: The JSON which gets merged into this JSON
+	
+	 - throws `ErrorWrongType` if the other JSONs differs in type on the top level.
+	 */
+    public mutating func merge(with other: JSON) throws {
+        try self.merge(with: other, typecheck: true)
+    }
+
+	/**
+	 Merges another JSON into this JSON and returns a new JSON, whereas primitive values which are not present in this JSON are getting added,
+	 present values getting overwritten, array values getting appended and nested JSONS getting merged the same way.
+	
+	 - parameter other: The JSON which gets merged into this JSON
+	
+	 - throws `ErrorWrongType` if the other JSONs differs in type on the top level.
+	
+	 - returns: New merged JSON
+	 */
+    public func merged(with other: JSON) throws -> JSON {
+        var merged = self
+        try merged.merge(with: other, typecheck: true)
+        return merged
+    }
+
+    /**
+     Private woker function which does the actual merging
+     Typecheck is set to true for the first recursion level to prevent total override of the source JSON
+ 	*/
+ 	fileprivate mutating func merge(with other: JSON, typecheck: Bool) throws {
+        if type == other.type {
+            switch type {
+            case .dictionary:
+                for (key, _) in other {
+                    try self[key].merge(with: other[key], typecheck: false)
+                }
+            case .array:
+                self = JSON(arrayValue + other.arrayValue)
+            default:
+                self = other
+            }
+        } else {
+            if typecheck {
+                throw SwiftyJSONError.wrongType
+            } else {
+                self = other
+            }
+        }
+    }
+
+    /// Private object
+    fileprivate var rawArray: [Any] = []
+    fileprivate var rawDictionary: [String: Any] = [:]
+    fileprivate var rawString: String = ""
+    fileprivate var rawNumber: NSNumber = 0
+    fileprivate var rawNull: NSNull = NSNull()
+    fileprivate var rawBool: Bool = false
+
+    /// JSON type, fileprivate setter
+    public fileprivate(set) var type: Type = .null
+
+    /// Error in JSON, fileprivate setter
+    public fileprivate(set) var error: SwiftyJSONError?
+
+    /// Object in JSON
+    public var object: Any {
+        get {
+            switch type {
+            case .array:      return rawArray
+            case .dictionary: return rawDictionary
+            case .string:     return rawString
+            case .number:     return rawNumber
+            case .bool:       return rawBool
+            default:          return rawNull
+            }
+        }
+        set {
+            error = nil
+            switch unwrap(newValue) {
+            case let number as NSNumber:
+                if number.isBool {
+                    type = .bool
+                    rawBool = number.boolValue
+                } else {
+                    type = .number
+                    rawNumber = number
+                }
+            case let string as String:
+                type = .string
+                rawString = string
+            case _ as NSNull:
+                type = .null
+            case nil:
+                type = .null
+            case let array as [Any]:
+                type = .array
+                rawArray = array
+            case let dictionary as [String: Any]:
+                type = .dictionary
+                rawDictionary = dictionary
+            default:
+                type = .unknown
+                error = SwiftyJSONError.unsupportedType
+            }
+        }
+    }
+
+    /// The static null JSON
+    @available(*, unavailable, renamed:"null")
+    public static var nullJSON: JSON { return null }
+    public static var null: JSON { return JSON(NSNull()) }
+}
+
+/// Private method to unwarp an object recursively
+private func unwrap(_ object: Any) -> Any {
+    switch object {
+    case let json as JSON:
+        return unwrap(json.object)
+    case let array as [Any]:
+        return array.map(unwrap)
+    case let dictionary as [String: Any]:
+        var d = dictionary
+        dictionary.forEach { pair in
+            d[pair.key] = unwrap(pair.value)
+        }
+        return d
+    default:
+        return object
+    }
+}
+
+public enum Index<T: Any>: Comparable {
+    case array(Int)
+    case dictionary(DictionaryIndex<String, T>)
+    case null
+
+    static public func == (lhs: Index, rhs: Index) -> Bool {
+        switch (lhs, rhs) {
+        case (.array(let left), .array(let right)):           return left == right
+        case (.dictionary(let left), .dictionary(let right)): return left == right
+        case (.null, .null):                                  return true
+        default:                                              return false
+        }
+    }
+
+    static public func < (lhs: Index, rhs: Index) -> Bool {
+        switch (lhs, rhs) {
+        case (.array(let left), .array(let right)):           return left < right
+        case (.dictionary(let left), .dictionary(let right)): return left < right
+        default:                                              return false
+        }
+    }
+}
+
+public typealias JSONIndex = Index<JSON>
+public typealias JSONRawIndex = Index<Any>
+
+extension JSON: Swift.Collection {
+
+    public typealias Index = JSONRawIndex
+
+    public var startIndex: Index {
+        switch type {
+        case .array:      return .array(rawArray.startIndex)
+        case .dictionary: return .dictionary(rawDictionary.startIndex)
+        default:          return .null
+        }
+    }
+
+    public var endIndex: Index {
+        switch type {
+        case .array:      return .array(rawArray.endIndex)
+        case .dictionary: return .dictionary(rawDictionary.endIndex)
+        default:          return .null
+        }
+    }
+
+    public func index(after i: Index) -> Index {
+        switch i {
+        case .array(let idx):      return .array(rawArray.index(after: idx))
+        case .dictionary(let idx): return .dictionary(rawDictionary.index(after: idx))
+        default:                   return .null
+        }
+    }
+
+    public subscript (position: Index) -> (String, JSON) {
+        switch position {
+        case .array(let idx):      return (String(idx), JSON(rawArray[idx]))
+        case .dictionary(let idx): return (rawDictionary[idx].key, JSON(rawDictionary[idx].value))
+        default:                   return ("", JSON.null)
+        }
+    }
+}
+
+// MARK: - Subscript
+
+/**
+ *  To mark both String and Int can be used in subscript.
+ */
+public enum JSONKey {
+    case index(Int)
+    case key(String)
+}
+
+public protocol JSONSubscriptType {
+    var jsonKey: JSONKey { get }
+}
+
+extension Int: JSONSubscriptType {
+    public var jsonKey: JSONKey {
+        return JSONKey.index(self)
+    }
+}
+
+extension String: JSONSubscriptType {
+    public var jsonKey: JSONKey {
+        return JSONKey.key(self)
+    }
+}
+
+extension JSON {
+
+    /// If `type` is `.array`, return json whose object is `array[index]`, otherwise return null json with error.
+    fileprivate subscript(index index: Int) -> JSON {
+        get {
+            if type != .array {
+                var r = JSON.null
+                r.error = self.error ?? SwiftyJSONError.wrongType
+                return r
+            } else if rawArray.indices.contains(index) {
+                return JSON(rawArray[index])
+            } else {
+                var r = JSON.null
+                r.error = SwiftyJSONError.indexOutOfBounds
+                return r
+            }
+        }
+        set {
+            if type == .array &&
+                rawArray.indices.contains(index) &&
+                newValue.error == nil {
+                rawArray[index] = newValue.object
+            }
+        }
+    }
+
+    /// If `type` is `.dictionary`, return json whose object is `dictionary[key]` , otherwise return null json with error.
+    fileprivate subscript(key key: String) -> JSON {
+        get {
+            var r = JSON.null
+            if type == .dictionary {
+                if let o = rawDictionary[key] {
+                    r = JSON(o)
+                } else {
+                    r.error = SwiftyJSONError.notExist
+                }
+            } else {
+                r.error = self.error ?? SwiftyJSONError.wrongType
+            }
+            return r
+        }
+        set {
+            if type == .dictionary && newValue.error == nil {
+                rawDictionary[key] = newValue.object
+            }
+        }
+    }
+
+    /// If `sub` is `Int`, return `subscript(index:)`; If `sub` is `String`,  return `subscript(key:)`.
+    fileprivate subscript(sub sub: JSONSubscriptType) -> JSON {
+        get {
+            switch sub.jsonKey {
+            case .index(let index): return self[index: index]
+            case .key(let key):     return self[key: key]
+            }
+        }
+        set {
+            switch sub.jsonKey {
+            case .index(let index): self[index: index] = newValue
+            case .key(let key):     self[key: key] = newValue
+            }
+        }
+    }
+
+	/**
+	 Find a json in the complex data structures by using array of Int and/or String as path.
+	
+	 Example:
+	
+	 ```
+	 let json = JSON[data]
+	 let path = [9,"list","person","name"]
+	 let name = json[path]
+	 ```
+	
+	 The same as: let name = json[9]["list"]["person"]["name"]
+	
+	 - parameter path: The target json's path.
+	
+	 - returns: Return a json found by the path or a null json with error
+	 */
+    public subscript(path: [JSONSubscriptType]) -> JSON {
+        get {
+            return path.reduce(self) { $0[sub: $1] }
+        }
+        set {
+            switch path.count {
+            case 0: return
+            case 1: self[sub:path[0]].object = newValue.object
+            default:
+                var aPath = path
+                aPath.remove(at: 0)
+                var nextJSON = self[sub: path[0]]
+                nextJSON[aPath] = newValue
+                self[sub: path[0]] = nextJSON
+            }
+        }
+    }
+
+    /**
+     Find a json in the complex data structures by using array of Int and/or String as path.
+
+     - parameter path: The target json's path. Example:
+
+     let name = json[9,"list","person","name"]
+
+     The same as: let name = json[9]["list"]["person"]["name"]
+
+     - returns: Return a json found by the path or a null json with error
+     */
+    public subscript(path: JSONSubscriptType...) -> JSON {
+        get {
+            return self[path]
+        }
+        set {
+            self[path] = newValue
+        }
+    }
+}
+
+// MARK: - LiteralConvertible
+
+extension JSON: Swift.ExpressibleByStringLiteral {
+
+    public init(stringLiteral value: StringLiteralType) {
+        self.init(value)
+    }
+
+    public init(extendedGraphemeClusterLiteral value: StringLiteralType) {
+        self.init(value)
+    }
+
+    public init(unicodeScalarLiteral value: StringLiteralType) {
+        self.init(value)
+    }
+}
+
+extension JSON: Swift.ExpressibleByIntegerLiteral {
+
+    public init(integerLiteral value: IntegerLiteralType) {
+        self.init(value)
+    }
+}
+
+extension JSON: Swift.ExpressibleByBooleanLiteral {
+
+    public init(booleanLiteral value: BooleanLiteralType) {
+        self.init(value)
+    }
+}
+
+extension JSON: Swift.ExpressibleByFloatLiteral {
+
+    public init(floatLiteral value: FloatLiteralType) {
+        self.init(value)
+    }
+}
+
+extension JSON: Swift.ExpressibleByDictionaryLiteral {
+    public init(dictionaryLiteral elements: (String, Any)...) {
+        let dictionary = elements.reduce(into: [String: Any](), { $0[$1.0] = $1.1})
+        self.init(dictionary)
+    }
+}
+
+extension JSON: Swift.ExpressibleByArrayLiteral {
+
+    public init(arrayLiteral elements: Any...) {
+        self.init(elements)
+    }
+}
+
+// MARK: - Raw
+
+extension JSON: Swift.RawRepresentable {
+
+    public init?(rawValue: Any) {
+        if JSON(rawValue).type == .unknown {
+            return nil
+        } else {
+            self.init(rawValue)
+        }
+    }
+
+    public var rawValue: Any {
+        return object
+    }
+
+    public func rawData(options opt: JSONSerialization.WritingOptions = JSONSerialization.WritingOptions(rawValue: 0)) throws -> Data {
+        guard JSONSerialization.isValidJSONObject(object) else {
+            throw SwiftyJSONError.invalidJSON
+        }
+
+        return try JSONSerialization.data(withJSONObject: object, options: opt)
+	}
+
+	public func rawString(_ encoding: String.Encoding = .utf8, options opt: JSONSerialization.WritingOptions = .prettyPrinted) -> String? {
+		do {
+			return try _rawString(encoding, options: [.jsonSerialization: opt])
+		} catch {
+			print("Could not serialize object to JSON because:", error.localizedDescription)
+			return nil
+		}
+	}
+
+	public func rawString(_ options: [writingOptionsKeys: Any]) -> String? {
+		let encoding = options[.encoding] as? String.Encoding ?? String.Encoding.utf8
+		let maxObjectDepth = options[.maxObjextDepth] as? Int ?? 10
+		do {
+			return try _rawString(encoding, options: options, maxObjectDepth: maxObjectDepth)
+		} catch {
+			print("Could not serialize object to JSON because:", error.localizedDescription)
+			return nil
+		}
+	}
+
+	fileprivate func _rawString(_ encoding: String.Encoding = .utf8, options: [writingOptionsKeys: Any], maxObjectDepth: Int = 10) throws -> String? {
+        guard maxObjectDepth > 0 else { throw SwiftyJSONError.invalidJSON }
+        switch type {
+        case .dictionary:
+			do {
+				if !(options[.castNilToNSNull] as? Bool ?? false) {
+					let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted
+					let data = try rawData(options: jsonOption)
+					return String(data: data, encoding: encoding)
+				}
+
+				guard let dict = object as? [String: Any?] else {
+					return nil
+				}
+				let body = try dict.keys.map { key throws -> String in
+					guard let value = dict[key] else {
+						return "\"\(key)\": null"
+					}
+					guard let unwrappedValue = value else {
+						return "\"\(key)\": null"
+					}
+
+					let nestedValue = JSON(unwrappedValue)
+					guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else {
+						throw SwiftyJSONError.elementTooDeep
+					}
+					if nestedValue.type == .string {
+						return "\"\(key)\": \"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\""
+					} else {
+						return "\"\(key)\": \(nestedString)"
+					}
+				}
+
+				return "{\(body.joined(separator: ","))}"
+			} catch _ {
+				return nil
+			}
+        case .array:
+            do {
+				if !(options[.castNilToNSNull] as? Bool ?? false) {
+					let jsonOption = options[.jsonSerialization] as? JSONSerialization.WritingOptions ?? JSONSerialization.WritingOptions.prettyPrinted
+					let data = try rawData(options: jsonOption)
+					return String(data: data, encoding: encoding)
+				}
+
+                guard let array = object as? [Any?] else {
+                    return nil
+                }
+                let body = try array.map { value throws -> String in
+                    guard let unwrappedValue = value else {
+                        return "null"
+                    }
+
+                    let nestedValue = JSON(unwrappedValue)
+                    guard let nestedString = try nestedValue._rawString(encoding, options: options, maxObjectDepth: maxObjectDepth - 1) else {
+                        throw SwiftyJSONError.invalidJSON
+                    }
+                    if nestedValue.type == .string {
+                        return "\"\(nestedString.replacingOccurrences(of: "\\", with: "\\\\").replacingOccurrences(of: "\"", with: "\\\""))\""
+                    } else {
+                        return nestedString
+                    }
+                }
+
+                return "[\(body.joined(separator: ","))]"
+            } catch _ {
+                return nil
+            }
+        case .string: return rawString
+        case .number: return rawNumber.stringValue
+        case .bool:   return rawBool.description
+        case .null:   return "null"
+        default:      return nil
+        }
+    }
+}
+
+// MARK: - Printable, DebugPrintable
+
+extension JSON: Swift.CustomStringConvertible, Swift.CustomDebugStringConvertible {
+
+    public var description: String {
+        return rawString(options: .prettyPrinted) ?? "unknown"
+    }
+
+    public var debugDescription: String {
+        return description
+    }
+}
+
+// MARK: - Array
+
+extension JSON {
+
+    //Optional [JSON]
+    public var array: [JSON]? {
+        return type == .array ? rawArray.map { JSON($0) } : nil
+    }
+
+    //Non-optional [JSON]
+    public var arrayValue: [JSON] {
+        return self.array ?? []
+    }
+
+    //Optional [Any]
+    public var arrayObject: [Any]? {
+        get {
+            switch type {
+            case .array: return rawArray
+            default:     return nil
+            }
+        }
+        set {
+            self.object = newValue ?? NSNull()
+        }
+    }
+}
+
+// MARK: - Dictionary
+
+extension JSON {
+
+    //Optional [String : JSON]
+    public var dictionary: [String: JSON]? {
+        if type == .dictionary {
+            var d = [String: JSON](minimumCapacity: rawDictionary.count)
+            rawDictionary.forEach { pair in
+                d[pair.key] = JSON(pair.value)
+            }
+            return d
+        } else {
+            return nil
+        }
+    }
+
+    //Non-optional [String : JSON]
+    public var dictionaryValue: [String: JSON] {
+        return dictionary ?? [:]
+    }
+
+    //Optional [String : Any]
+
+    public var dictionaryObject: [String: Any]? {
+        get {
+            switch type {
+            case .dictionary: return rawDictionary
+            default:          return nil
+            }
+        }
+        set {
+            object = newValue ?? NSNull()
+        }
+    }
+}
+
+// MARK: - Bool
+
+extension JSON { // : Swift.Bool
+
+    //Optional bool
+    public var bool: Bool? {
+        get {
+            switch type {
+            case .bool: return rawBool
+            default:    return nil
+            }
+        }
+        set {
+            object = newValue ?? NSNull()
+        }
+    }
+
+    //Non-optional bool
+    public var boolValue: Bool {
+        get {
+            switch type {
+            case .bool:   return rawBool
+            case .number: return rawNumber.boolValue
+            case .string: return ["true", "y", "t", "yes", "1"].contains { rawString.caseInsensitiveCompare($0) == .orderedSame }
+            default:      return false
+            }
+        }
+        set {
+            object = newValue
+        }
+    }
+}
+
+// MARK: - String
+
+extension JSON {
+
+    //Optional string
+    public var string: String? {
+        get {
+            switch type {
+            case .string: return object as? String
+            default:      return nil
+            }
+        }
+        set {
+            object = newValue ?? NSNull()
+        }
+    }
+
+    //Non-optional string
+    public var stringValue: String {
+        get {
+            switch type {
+            case .string: return object as? String ?? ""
+            case .number: return rawNumber.stringValue
+            case .bool:   return (object as? Bool).map { String($0) } ?? ""
+            default:      return ""
+            }
+        }
+        set {
+            object = newValue
+        }
+    }
+}
+
+// MARK: - Number
+
+extension JSON {
+
+    //Optional number
+    public var number: NSNumber? {
+        get {
+            switch type {
+            case .number: return rawNumber
+            case .bool:   return NSNumber(value: rawBool ? 1 : 0)
+            default:      return nil
+            }
+        }
+        set {
+            object = newValue ?? NSNull()
+        }
+    }
+
+    //Non-optional number
+    public var numberValue: NSNumber {
+        get {
+            switch type {
+            case .string:
+                let decimal = NSDecimalNumber(string: object as? String)
+                return decimal == .notANumber ? .zero : decimal
+            case .number: return object as? NSNumber ?? NSNumber(value: 0)
+            case .bool: return NSNumber(value: rawBool ? 1 : 0)
+            default: return NSNumber(value: 0.0)
+            }
+        }
+        set {
+            object = newValue
+        }
+    }
+}
+
+// MARK: - Null
+
+extension JSON {
+
+    public var null: NSNull? {
+        set {
+            object = NSNull()
+        }
+        get {
+            switch type {
+            case .null: return rawNull
+            default:    return nil
+            }
+        }
+    }
+    public func exists() -> Bool {
+        if let errorValue = error, (400...1000).contains(errorValue.errorCode) {
+            return false
+        }
+        return true
+    }
+}
+
+// MARK: - URL
+
+extension JSON {
+
+    //Optional URL
+    public var url: URL? {
+        get {
+            switch type {
+            case .string:
+                // Check for existing percent escapes first to prevent double-escaping of % character
+                if rawString.range(of: "%[0-9A-Fa-f]{2}", options: .regularExpression, range: nil, locale: nil) != nil {
+                    return Foundation.URL(string: rawString)
+                } else if let encodedString_ = rawString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) {
+                    // We have to use `Foundation.URL` otherwise it conflicts with the variable name.
+                    return Foundation.URL(string: encodedString_)
+                } else {
+                    return nil
+                }
+            default:
+                return nil
+            }
+        }
+        set {
+            object = newValue?.absoluteString ?? NSNull()
+        }
+    }
+}
+
+// MARK: - Int, Double, Float, Int8, Int16, Int32, Int64
+
+extension JSON {
+
+    public var double: Double? {
+        get {
+            return number?.doubleValue
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object = NSNull()
+            }
+        }
+    }
+
+    public var doubleValue: Double {
+        get {
+            return numberValue.doubleValue
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var float: Float? {
+        get {
+            return number?.floatValue
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object = NSNull()
+            }
+        }
+    }
+
+    public var floatValue: Float {
+        get {
+            return numberValue.floatValue
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var int: Int? {
+        get {
+            return number?.intValue
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object = NSNull()
+            }
+        }
+    }
+
+    public var intValue: Int {
+        get {
+            return numberValue.intValue
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var uInt: UInt? {
+        get {
+            return number?.uintValue
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object = NSNull()
+            }
+        }
+    }
+
+    public var uIntValue: UInt {
+        get {
+            return numberValue.uintValue
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var int8: Int8? {
+        get {
+            return number?.int8Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: Int(newValue))
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var int8Value: Int8 {
+        get {
+            return numberValue.int8Value
+        }
+        set {
+            object = NSNumber(value: Int(newValue))
+        }
+    }
+
+    public var uInt8: UInt8? {
+        get {
+            return number?.uint8Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var uInt8Value: UInt8 {
+        get {
+            return numberValue.uint8Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var int16: Int16? {
+        get {
+            return number?.int16Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var int16Value: Int16 {
+        get {
+            return numberValue.int16Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var uInt16: UInt16? {
+        get {
+            return number?.uint16Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var uInt16Value: UInt16 {
+        get {
+            return numberValue.uint16Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var int32: Int32? {
+        get {
+            return number?.int32Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var int32Value: Int32 {
+        get {
+            return numberValue.int32Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var uInt32: UInt32? {
+        get {
+            return number?.uint32Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var uInt32Value: UInt32 {
+        get {
+            return numberValue.uint32Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var int64: Int64? {
+        get {
+            return number?.int64Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var int64Value: Int64 {
+        get {
+            return numberValue.int64Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+
+    public var uInt64: UInt64? {
+        get {
+            return number?.uint64Value
+        }
+        set {
+            if let newValue = newValue {
+                object = NSNumber(value: newValue)
+            } else {
+                object =  NSNull()
+            }
+        }
+    }
+
+    public var uInt64Value: UInt64 {
+        get {
+            return numberValue.uint64Value
+        }
+        set {
+            object = NSNumber(value: newValue)
+        }
+    }
+}
+
+// MARK: - Comparable
+
+extension JSON: Swift.Comparable {}
+
+public func == (lhs: JSON, rhs: JSON) -> Bool {
+
+    switch (lhs.type, rhs.type) {
+    case (.number, .number): return lhs.rawNumber == rhs.rawNumber
+    case (.string, .string): return lhs.rawString == rhs.rawString
+    case (.bool, .bool):     return lhs.rawBool == rhs.rawBool
+    case (.array, .array):   return lhs.rawArray as NSArray == rhs.rawArray as NSArray
+    case (.dictionary, .dictionary): return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
+    case (.null, .null):     return true
+    default:                 return false
+    }
+}
+
+public func <= (lhs: JSON, rhs: JSON) -> Bool {
+
+    switch (lhs.type, rhs.type) {
+    case (.number, .number): return lhs.rawNumber <= rhs.rawNumber
+    case (.string, .string): return lhs.rawString <= rhs.rawString
+    case (.bool, .bool):     return lhs.rawBool == rhs.rawBool
+    case (.array, .array):   return lhs.rawArray as NSArray == rhs.rawArray as NSArray
+    case (.dictionary, .dictionary): return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
+    case (.null, .null):     return true
+    default:                 return false
+    }
+}
+
+public func >= (lhs: JSON, rhs: JSON) -> Bool {
+
+    switch (lhs.type, rhs.type) {
+    case (.number, .number): return lhs.rawNumber >= rhs.rawNumber
+    case (.string, .string): return lhs.rawString >= rhs.rawString
+    case (.bool, .bool):     return lhs.rawBool == rhs.rawBool
+    case (.array, .array):   return lhs.rawArray as NSArray == rhs.rawArray as NSArray
+    case (.dictionary, .dictionary): return lhs.rawDictionary as NSDictionary == rhs.rawDictionary as NSDictionary
+    case (.null, .null):     return true
+    default:                 return false
+    }
+}
+
+public func > (lhs: JSON, rhs: JSON) -> Bool {
+
+    switch (lhs.type, rhs.type) {
+    case (.number, .number): return lhs.rawNumber > rhs.rawNumber
+    case (.string, .string): return lhs.rawString > rhs.rawString
+    default:                 return false
+    }
+}
+
+public func < (lhs: JSON, rhs: JSON) -> Bool {
+
+    switch (lhs.type, rhs.type) {
+    case (.number, .number): return lhs.rawNumber < rhs.rawNumber
+    case (.string, .string): return lhs.rawString < rhs.rawString
+    default:                 return false
+    }
+}
+
+private let trueNumber = NSNumber(value: true)
+private let falseNumber = NSNumber(value: false)
+private let trueObjCType = String(cString: trueNumber.objCType)
+private let falseObjCType = String(cString: falseNumber.objCType)
+
+// MARK: - NSNumber: Comparable
+
+extension NSNumber {
+    fileprivate var isBool: Bool {
+        let objCType = String(cString: self.objCType)
+        if (self.compare(trueNumber) == .orderedSame && objCType == trueObjCType) || (self.compare(falseNumber) == .orderedSame && objCType == falseObjCType) {
+            return true
+        } else {
+            return false
+        }
+    }
+}
+
+func == (lhs: NSNumber, rhs: NSNumber) -> Bool {
+    switch (lhs.isBool, rhs.isBool) {
+    case (false, true): return false
+    case (true, false): return false
+    default:            return lhs.compare(rhs) == .orderedSame
+    }
+}
+
+func != (lhs: NSNumber, rhs: NSNumber) -> Bool {
+    return !(lhs == rhs)
+}
+
+func < (lhs: NSNumber, rhs: NSNumber) -> Bool {
+
+    switch (lhs.isBool, rhs.isBool) {
+    case (false, true): return false
+    case (true, false): return false
+    default:            return lhs.compare(rhs) == .orderedAscending
+    }
+}
+
+func > (lhs: NSNumber, rhs: NSNumber) -> Bool {
+
+    switch (lhs.isBool, rhs.isBool) {
+    case (false, true): return false
+    case (true, false): return false
+    default:            return lhs.compare(rhs) == ComparisonResult.orderedDescending
+    }
+}
+
+func <= (lhs: NSNumber, rhs: NSNumber) -> Bool {
+
+    switch (lhs.isBool, rhs.isBool) {
+    case (false, true): return false
+    case (true, false): return false
+    default:            return lhs.compare(rhs) != .orderedDescending
+    }
+}
+
+func >= (lhs: NSNumber, rhs: NSNumber) -> Bool {
+
+    switch (lhs.isBool, rhs.isBool) {
+    case (false, true): return false
+    case (true, false): return false
+    default:            return lhs.compare(rhs) != .orderedAscending
+    }
+}
+
+public enum writingOptionsKeys {
+	case jsonSerialization
+	case castNilToNSNull
+	case maxObjextDepth
+	case encoding
+}
+
+// MARK: - JSON: Codable
+extension JSON: Codable {
+    private static var codableTypes: [Codable.Type] {
+        return [
+            Bool.self,
+            Int.self,
+            Int8.self,
+            Int16.self,
+            Int32.self,
+            Int64.self,
+            UInt.self,
+            UInt8.self,
+            UInt16.self,
+            UInt32.self,
+            UInt64.self,
+            Double.self,
+            String.self,
+            [JSON].self,
+            [String: JSON].self
+        ]
+    }
+    public init(from decoder: Decoder) throws {
+        var object: Any?
+
+        if let container = try? decoder.singleValueContainer(), !container.decodeNil() {
+            for type in JSON.codableTypes {
+                if object != nil {
+                    break
+                }
+                // try to decode value
+                switch type {
+                case let boolType as Bool.Type:
+                    object = try? container.decode(boolType)
+                case let intType as Int.Type:
+                    object = try? container.decode(intType)
+                case let int8Type as Int8.Type:
+                    object = try? container.decode(int8Type)
+                case let int32Type as Int32.Type:
+                    object = try? container.decode(int32Type)
+                case let int64Type as Int64.Type:
+                    object = try? container.decode(int64Type)
+                case let uintType as UInt.Type:
+                    object = try? container.decode(uintType)
+                case let uint8Type as UInt8.Type:
+                    object = try? container.decode(uint8Type)
+                case let uint16Type as UInt16.Type:
+                    object = try? container.decode(uint16Type)
+                case let uint32Type as UInt32.Type:
+                    object = try? container.decode(uint32Type)
+                case let uint64Type as UInt64.Type:
+                    object = try? container.decode(uint64Type)
+                case let doubleType as Double.Type:
+                    object = try? container.decode(doubleType)
+                case let stringType as String.Type:
+                    object = try? container.decode(stringType)
+                case let jsonValueArrayType as [JSON].Type:
+                    object = try? container.decode(jsonValueArrayType)
+                case let jsonValueDictType as [String: JSON].Type:
+                    object = try? container.decode(jsonValueDictType)
+                default:
+                    break
+                }
+            }
+        }
+        self.init(object ?? NSNull())
+    }
+    public func encode(to encoder: Encoder) throws {
+        var container = encoder.singleValueContainer()
+        if object is NSNull {
+            try container.encodeNil()
+            return
+        }
+        switch object {
+        case let intValue as Int:
+            try container.encode(intValue)
+        case let int8Value as Int8:
+            try container.encode(int8Value)
+        case let int32Value as Int32:
+            try container.encode(int32Value)
+        case let int64Value as Int64:
+            try container.encode(int64Value)
+        case let uintValue as UInt:
+            try container.encode(uintValue)
+        case let uint8Value as UInt8:
+            try container.encode(uint8Value)
+        case let uint16Value as UInt16:
+            try container.encode(uint16Value)
+        case let uint32Value as UInt32:
+            try container.encode(uint32Value)
+        case let uint64Value as UInt64:
+            try container.encode(uint64Value)
+        case let doubleValue as Double:
+            try container.encode(doubleValue)
+        case let boolValue as Bool:
+            try container.encode(boolValue)
+        case let stringValue as String:
+            try container.encode(stringValue)
+        case is [Any]:
+            let jsonValueArray = array ?? []
+            try container.encode(jsonValueArray)
+        case is [String: Any]:
+            let jsonValueDictValue = dictionary ?? [:]
+            try container.encode(jsonValueDictValue)
+        default:
+            break
+        }
+    }
+}

+ 25 - 0
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-acknowledgements.markdown

@@ -23,4 +23,29 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
+
+## SwiftyJSON
+
+The MIT License (MIT)
+
+Copyright (c) 2017 Ruoyu Fu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
 Generated by CocoaPods - https://cocoapods.org

+ 31 - 0
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-acknowledgements.plist

@@ -41,6 +41,37 @@ THE SOFTWARE.
 			<key>Type</key>
 			<string>PSGroupSpecifier</string>
 		</dict>
+		<dict>
+			<key>FooterText</key>
+			<string>The MIT License (MIT)
+
+Copyright (c) 2017 Ruoyu Fu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+</string>
+			<key>License</key>
+			<string>MIT</string>
+			<key>Title</key>
+			<string>SwiftyJSON</string>
+			<key>Type</key>
+			<string>PSGroupSpecifier</string>
+		</dict>
 		<dict>
 			<key>FooterText</key>
 			<string>Generated by CocoaPods - https://cocoapods.org</string>

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Debug-input-files.xcfilelist

@@ -1,2 +1,3 @@
 ${PODS_ROOT}/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks.sh
-${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Debug-output-files.xcfilelist

@@ -1 +1,2 @@
-${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Release-input-files.xcfilelist

@@ -1,2 +1,3 @@
 ${PODS_ROOT}/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks.sh
-${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks-Release-output-files.xcfilelist

@@ -1 +1,2 @@
-${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework

+ 2 - 0
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests-frameworks.sh

@@ -177,9 +177,11 @@ code_sign_if_enabled() {
 
 if [[ "$CONFIGURATION" == "Debug" ]]; then
   install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
+  install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework"
 fi
 if [[ "$CONFIGURATION" == "Release" ]]; then
   install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
+  install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework"
 fi
 if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
   wait

+ 3 - 3
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests.debug.xcconfig

@@ -1,11 +1,11 @@
 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
 CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
-FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
-HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers"
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers"
 LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift "$(PLATFORM_DIR)/Developer/Library/Frameworks" '@executable_path/Frameworks' '@loader_path/Frameworks'
 LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
-OTHER_LDFLAGS = $(inherited) -framework "SnapKit"
+OTHER_LDFLAGS = $(inherited) -framework "SnapKit" -framework "SwiftyJSON"
 OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
 PODS_BUILD_DIR = ${BUILD_DIR}
 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

+ 3 - 3
Pods/Target Support Files/Pods-AIPaint-AIPaintUITests/Pods-AIPaint-AIPaintUITests.release.xcconfig

@@ -1,11 +1,11 @@
 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
 CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
-FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
-HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers"
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers"
 LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift "$(PLATFORM_DIR)/Developer/Library/Frameworks" '@executable_path/Frameworks' '@loader_path/Frameworks'
 LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
-OTHER_LDFLAGS = $(inherited) -framework "SnapKit"
+OTHER_LDFLAGS = $(inherited) -framework "SnapKit" -framework "SwiftyJSON"
 OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
 PODS_BUILD_DIR = ${BUILD_DIR}
 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

+ 25 - 0
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-acknowledgements.markdown

@@ -23,4 +23,29 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 
+
+## SwiftyJSON
+
+The MIT License (MIT)
+
+Copyright (c) 2017 Ruoyu Fu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
 Generated by CocoaPods - https://cocoapods.org

+ 31 - 0
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-acknowledgements.plist

@@ -41,6 +41,37 @@ THE SOFTWARE.
 			<key>Type</key>
 			<string>PSGroupSpecifier</string>
 		</dict>
+		<dict>
+			<key>FooterText</key>
+			<string>The MIT License (MIT)
+
+Copyright (c) 2017 Ruoyu Fu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+</string>
+			<key>License</key>
+			<string>MIT</string>
+			<key>Title</key>
+			<string>SwiftyJSON</string>
+			<key>Type</key>
+			<string>PSGroupSpecifier</string>
+		</dict>
 		<dict>
 			<key>FooterText</key>
 			<string>Generated by CocoaPods - https://cocoapods.org</string>

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Debug-input-files.xcfilelist

@@ -1,2 +1,3 @@
 ${PODS_ROOT}/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks.sh
-${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Debug-output-files.xcfilelist

@@ -1 +1,2 @@
-${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Release-input-files.xcfilelist

@@ -1,2 +1,3 @@
 ${PODS_ROOT}/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks.sh
-${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework
+${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework

+ 2 - 1
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks-Release-output-files.xcfilelist

@@ -1 +1,2 @@
-${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SnapKit.framework
+${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework

+ 2 - 0
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint-frameworks.sh

@@ -177,9 +177,11 @@ code_sign_if_enabled() {
 
 if [[ "$CONFIGURATION" == "Debug" ]]; then
   install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
+  install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework"
 fi
 if [[ "$CONFIGURATION" == "Release" ]]; then
   install_framework "${BUILT_PRODUCTS_DIR}/SnapKit/SnapKit.framework"
+  install_framework "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework"
 fi
 if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
   wait

+ 3 - 3
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint.debug.xcconfig

@@ -1,11 +1,11 @@
 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
 CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
-FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
-HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers"
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers"
 LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks'
 LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
-OTHER_LDFLAGS = $(inherited) -framework "SnapKit"
+OTHER_LDFLAGS = $(inherited) -framework "SnapKit" -framework "SwiftyJSON"
 OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
 PODS_BUILD_DIR = ${BUILD_DIR}
 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

+ 3 - 3
Pods/Target Support Files/Pods-AIPaint/Pods-AIPaint.release.xcconfig

@@ -1,11 +1,11 @@
 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
 CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
-FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
-HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers"
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers"
 LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks'
 LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
-OTHER_LDFLAGS = $(inherited) -framework "SnapKit"
+OTHER_LDFLAGS = $(inherited) -framework "SnapKit" -framework "SwiftyJSON"
 OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
 PODS_BUILD_DIR = ${BUILD_DIR}
 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)

+ 3 - 3
Pods/Target Support Files/Pods-AIPaintTests/Pods-AIPaintTests.debug.xcconfig

@@ -1,8 +1,8 @@
 CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
-FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
-HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers"
-OTHER_LDFLAGS = $(inherited) -framework "SnapKit"
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers"
+OTHER_LDFLAGS = $(inherited) -framework "SnapKit" -framework "SwiftyJSON"
 PODS_BUILD_DIR = ${BUILD_DIR}
 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
 PODS_PODFILE_DIR_PATH = ${SRCROOT}/.

+ 3 - 3
Pods/Target Support Files/Pods-AIPaintTests/Pods-AIPaintTests.release.xcconfig

@@ -1,8 +1,8 @@
 CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
-FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
+FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON"
 GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
-HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers"
-OTHER_LDFLAGS = $(inherited) -framework "SnapKit"
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON/SwiftyJSON.framework/Headers"
+OTHER_LDFLAGS = $(inherited) -framework "SnapKit" -framework "SwiftyJSON"
 PODS_BUILD_DIR = ${BUILD_DIR}
 PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
 PODS_PODFILE_DIR_PATH = ${SRCROOT}/.

+ 26 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON-Info.plist

@@ -0,0 +1,26 @@
+<?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>CFBundleDevelopmentRegion</key>
+  <string>en</string>
+  <key>CFBundleExecutable</key>
+  <string>${EXECUTABLE_NAME}</string>
+  <key>CFBundleIdentifier</key>
+  <string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
+  <key>CFBundleInfoDictionaryVersion</key>
+  <string>6.0</string>
+  <key>CFBundleName</key>
+  <string>${PRODUCT_NAME}</string>
+  <key>CFBundlePackageType</key>
+  <string>FMWK</string>
+  <key>CFBundleShortVersionString</key>
+  <string>4.3.0</string>
+  <key>CFBundleSignature</key>
+  <string>????</string>
+  <key>CFBundleVersion</key>
+  <string>${CURRENT_PROJECT_VERSION}</string>
+  <key>NSPrincipalClass</key>
+  <string></string>
+</dict>
+</plist>

+ 5 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON-dummy.m

@@ -0,0 +1,5 @@
+#import <Foundation/Foundation.h>
+@interface PodsDummy_SwiftyJSON : NSObject
+@end
+@implementation PodsDummy_SwiftyJSON
+@end

+ 12 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON-prefix.pch

@@ -0,0 +1,12 @@
+#ifdef __OBJC__
+#import <UIKit/UIKit.h>
+#else
+#ifndef FOUNDATION_EXPORT
+#if defined(__cplusplus)
+#define FOUNDATION_EXPORT extern "C"
+#else
+#define FOUNDATION_EXPORT extern
+#endif
+#endif
+#endif
+

+ 16 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON-umbrella.h

@@ -0,0 +1,16 @@
+#ifdef __OBJC__
+#import <UIKit/UIKit.h>
+#else
+#ifndef FOUNDATION_EXPORT
+#if defined(__cplusplus)
+#define FOUNDATION_EXPORT extern "C"
+#else
+#define FOUNDATION_EXPORT extern
+#endif
+#endif
+#endif
+
+
+FOUNDATION_EXPORT double SwiftyJSONVersionNumber;
+FOUNDATION_EXPORT const unsigned char SwiftyJSONVersionString[];
+

+ 13 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON.debug.xcconfig

@@ -0,0 +1,13 @@
+CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
+CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON
+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
+LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
+OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
+PODS_BUILD_DIR = ${BUILD_DIR}
+PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
+PODS_ROOT = ${SRCROOT}
+PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftyJSON
+PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
+PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
+SKIP_INSTALL = YES
+USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES

+ 6 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON.modulemap

@@ -0,0 +1,6 @@
+framework module SwiftyJSON {
+  umbrella header "SwiftyJSON-umbrella.h"
+
+  export *
+  module * { export * }
+}

+ 13 - 0
Pods/Target Support Files/SwiftyJSON/SwiftyJSON.release.xcconfig

@@ -0,0 +1,13 @@
+CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO
+CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/SwiftyJSON
+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
+LIBRARY_SEARCH_PATHS = $(inherited) "${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift
+OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
+PODS_BUILD_DIR = ${BUILD_DIR}
+PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
+PODS_ROOT = ${SRCROOT}
+PODS_TARGET_SRCROOT = ${PODS_ROOT}/SwiftyJSON
+PODS_XCFRAMEWORKS_BUILD_DIR = $(PODS_CONFIGURATION_BUILD_DIR)/XCFrameworkIntermediates
+PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier}
+SKIP_INSTALL = YES
+USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES

Some files were not shown because too many files changed in this diff