Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahid Attique committed Jul 18, 2017
2 parents a8f24d9 93a789a commit 8be2d8e
Show file tree
Hide file tree
Showing 10 changed files with 397 additions and 48 deletions.
15 changes: 15 additions & 0 deletions FAParser.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 7,7 @@
objects = {

/* Begin PBXBuildFile section */
20899CCF1F15013600E990EC /* DataExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 20899CCE1F15013600E990EC /* DataExtension.swift */; };
29E26CA91F09204000A39D25 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29E26CA81F09204000A39D25 /* AppDelegate.swift */; };
29E26CAB1F09204000A39D25 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29E26CAA1F09204000A39D25 /* ViewController.swift */; };
29E26CAE1F09204000A39D25 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29E26CAC1F09204000A39D25 /* Main.storyboard */; };
Expand Down Expand Up @@ -39,6 40,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
20899CCE1F15013600E990EC /* DataExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DataExtension.swift; sourceTree = "<group>"; };
29E26CA51F09204000A39D25 /* FAParser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FAParser.app; sourceTree = BUILT_PRODUCTS_DIR; };
29E26CA81F09204000A39D25 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
29E26CAA1F09204000A39D25 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -84,6 86,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
20899CCD1F15012900E990EC /* Extensions */ = {
isa = PBXGroup;
children = (
20899CCE1F15013600E990EC /* DataExtension.swift */,
);
name = Extensions;
sourceTree = "<group>";
};
29E26C9C1F09203F00A39D25 = {
isa = PBXGroup;
children = (
Expand All @@ -110,6 120,7 @@
29E26CA71F09204000A39D25 /* FAParser */ = {
isa = PBXGroup;
children = (
20899CCD1F15012900E990EC /* Extensions */,
29E26CDC1F09211700A39D25 /* Models */,
29E26CD61F09205000A39D25 /* AppDelegate */,
29E26CD71F09205D00A39D25 /* Controllers */,
Expand Down Expand Up @@ -328,6 339,7 @@
buildActionMask = 2147483647;
files = (
29E26CAB1F09204000A39D25 /* ViewController.swift in Sources */,
20899CCF1F15013600E990EC /* DataExtension.swift in Sources */,
29E26CDF1F09222B00A39D25 /* FAParser.swift in Sources */,
29E26CE51F0934F300A39D25 /* README.md in Sources */,
29E26CA91F09204000A39D25 /* AppDelegate.swift in Sources */,
Expand Down Expand Up @@ -582,6 863,7 @@
29E26CCF1F09204000A39D25 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
29E26CD01F09204000A39D25 /* Build configuration list for PBXNativeTarget "FAParserTests" */ = {
isa = XCConfigurationList;
Expand All @@ -590,6 603,7 @@
29E26CD21F09204000A39D25 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
29E26CD31F09204000A39D25 /* Build configuration list for PBXNativeTarget "FAParserUITests" */ = {
isa = XCConfigurationList;
Expand All @@ -598,6 612,7 @@
29E26CD51F09204000A39D25 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29E26CA41F09203F00A39D25"
BuildableName = "FAParser.app"
BlueprintName = "FAParser"
ReferencedContainer = "container:FAParser.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29E26CB81F09204000A39D25"
BuildableName = "FAParserTests.xctest"
BlueprintName = "FAParserTests"
ReferencedContainer = "container:FAParser.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29E26CC31F09204000A39D25"
BuildableName = "FAParserUITests.xctest"
BlueprintName = "FAParserUITests"
ReferencedContainer = "container:FAParser.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29E26CA41F09203F00A39D25"
BuildableName = "FAParser.app"
BlueprintName = "FAParser"
ReferencedContainer = "container:FAParser.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</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">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29E26CA41F09203F00A39D25"
BuildableName = "FAParser.app"
BlueprintName = "FAParser"
ReferencedContainer = "container:FAParser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "29E26CA41F09203F00A39D25"
BuildableName = "FAParser.app"
BlueprintName = "FAParser"
ReferencedContainer = "container:FAParser.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>FAParser.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>29E26CA41F09203F00A39D25</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>29E26CB81F09204000A39D25</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>29E26CC31F09204000A39D25</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
55 changes: 55 additions & 0 deletions FAParser/Classes/FAParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 88,62 @@ public extension NSObject {
}
}

protocol AZJSONable {}

extension AZJSONable {
func toDictionary() -> [String:Any] {
var dict = [String:Any]()
let mirrorSelf = Mirror(reflecting: self)

dict = dictionaryAZRepresentation(mirror: mirrorSelf)

return dict
}

func dictionaryAZRepresentation(mirror: Mirror) -> [String: Any] {
var dict = [String:Any]()


for child in mirror.children {
if let key = child.label {

let valueMirror = Mirror(reflecting: child.value)

if let displayType = valueMirror.displayStyle {

if displayType == .class{

dict[key] = dictionaryAZRepresentation(mirror: valueMirror)

}
else if displayType == .collection {

var array = Array<[String: Any]>()

for ch in (child.value as! Array<Any>) {

let mir = Mirror(reflecting: ch)

array.append(dictionaryAZRepresentation(mirror: mir))

}

dict[key] = array
}
else if displayType == .optional {
dict[key] = (dictionaryAZRepresentation(mirror: valueMirror)["some"])

}
}
else {
dict[key] = child.value
}
}
}
return dict
}

}



Expand Down
55 changes: 55 additions & 0 deletions FAParser/DataExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 1,55 @@
//
// Dictionary Additions.swift
// Pods
//
// Created by Muhammad Afroz on 5/8/17.
//
//

import Foundation
import UIKit

extension Dictionary {

mutating func merge(with dictionary: Dictionary) {
dictionary.forEach { updateValue($1, forKey: $0) }
}

func merged(with dictionary: Dictionary) -> Dictionary {
var dict = self
dict.merge(with: dictionary)
return dict
}
public func has(key: Key) -> Bool {
return index(forKey: key) != nil
}

public mutating func removeAll(keys: [Key]) {
keys.forEach({ removeValue(forKey: $0)})
}

public func jsonData(prettify: Bool = false) -> Data? {
guard JSONSerialization.isValidJSONObject(self) else {
return nil
}
let options = (prettify == true) ? JSONSerialization.WritingOptions.prettyPrinted : JSONSerialization.WritingOptions()
return try? JSONSerialization.data(withJSONObject: self, options: options)
}
public func jsonString(prettify: Bool = false) -> String? {
guard JSONSerialization.isValidJSONObject(self) else {
return nil
}
let options = (prettify == true) ? JSONSerialization.WritingOptions.prettyPrinted : JSONSerialization.WritingOptions()
let jsonData = try? JSONSerialization.data(withJSONObject: self, options: options)
return jsonData?.string(encoding: .utf8)
}

}
// MARK: - Methods
public extension Data {

public func string(encoding: String.Encoding) -> String? {
return String(data: self, encoding: encoding)
}

}
Loading

0 comments on commit 8be2d8e

Please sign in to comment.