diff --git a/Source/Codable/Codable.swift b/Source/Codable/Codable.swift index 695a2ee..e8da088 100644 --- a/Source/Codable/Codable.swift +++ b/Source/Codable/Codable.swift @@ -105,15 +105,17 @@ public extension Decodable { - parameter data: The json data - parameter keyPath: for if you want something else than the root object */ - init(data: Data, keyPath: String? = nil) throws { + init(data: Data, keyPath: String? = nil, codingStragegy: JSONDecoder.KeyDecodingStrategy = .convertFromSnakeCase) throws { + let decoder = JSONDecoder() + decoder.keyDecodingStrategy = .convertFromSnakeCase if let keyPath = keyPath { let topLevel = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) guard let nestedJson = (topLevel as AnyObject).value(forKeyPath: keyPath) else { throw CodingError.RuntimeError("Cannot decode data to object") } let nestedData = try JSONSerialization.data(withJSONObject: nestedJson) - self = try JSONDecoder().decode(Self.self, from: nestedData) + self = try decoder.decode(Self.self, from: nestedData) return } - self = try JSONDecoder().decode(Self.self, from: data) + self = try decoder.decode(Self.self, from: data) } /** diff --git a/Stuff.podspec b/Stuff.podspec index 26fcb82..e55d812 100755 --- a/Stuff.podspec +++ b/Stuff.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Stuff" - s.version = "0.6.0" + s.version = "0.6.1" s.summary = "Too small for a library, too important to just forget" s.description = <<-EOS diff --git a/Stuff.xcodeproj/project.pbxproj b/Stuff.xcodeproj/project.pbxproj index dca09c7..8436cdf 100755 --- a/Stuff.xcodeproj/project.pbxproj +++ b/Stuff.xcodeproj/project.pbxproj @@ -107,7 +107,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = evict; TargetAttributes = { 7F29F3761E4E05070048B915 = { @@ -222,6 +222,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -229,6 +230,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -278,6 +280,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -285,6 +288,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -323,7 +327,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = nl.evict.StuffTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; }; name = Debug; @@ -337,7 +340,6 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = nl.evict.StuffTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; }; name = Release; diff --git a/Stuff.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Stuff.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Stuff.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +