Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Move some things into a deprecated file. #8
Browse files Browse the repository at this point in the history
  • Loading branch information
calebd committed Nov 20, 2015
1 parent 27543c2 commit 8bef09f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 51 deletions.
10 changes: 10 additions & 0 deletions Alexander.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
3A512F071BE16B250091A124 /* JSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BEDAE5C1B5DC4B200AD52FE /* JSON.swift */; };
3A512F081BE16B250091A124 /* JSONCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B62AADB1B824C1200491A67 /* JSONCodable.swift */; };
3A512F091BE16B250091A124 /* Defines.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B62AAD81B82452800491A67 /* Defines.swift */; };
3AA08DDA1BFE417C001BCA4D /* Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA08DD91BFE417C001BCA4D /* Deprecated.swift */; };
3AA08DDB1BFE417C001BCA4D /* Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA08DD91BFE417C001BCA4D /* Deprecated.swift */; };
3AA08DDC1BFE417C001BCA4D /* Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA08DD91BFE417C001BCA4D /* Deprecated.swift */; };
3AA08DDD1BFE417C001BCA4D /* Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AA08DD91BFE417C001BCA4D /* Deprecated.swift */; };
3AE5C3941BFD3EBC00F1080F /* AlexanderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE5C3931BFD3EBC00F1080F /* AlexanderTests.swift */; };
3AE5C3951BFD3EBC00F1080F /* AlexanderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE5C3931BFD3EBC00F1080F /* AlexanderTests.swift */; };
3AE5C3961BFD3EBC00F1080F /* AlexanderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3AE5C3931BFD3EBC00F1080F /* AlexanderTests.swift */; };
Expand Down Expand Up @@ -77,6 +81,7 @@
3A512F0E1BE16BB60091A124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3A512F101BE16BB60091A124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3A512F121BE16BB60091A124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3AA08DD91BFE417C001BCA4D /* Deprecated.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Deprecated.swift; sourceTree = "<group>"; };
3AE5C3931BFD3EBC00F1080F /* AlexanderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlexanderTests.swift; sourceTree = "<group>"; };
3AE5C39B1BFD522300F1080F /* DecoderType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DecoderType.swift; sourceTree = "<group>"; };
3AE5C3A01BFD551800F1080F /* UserDecoderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDecoderTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -266,6 +271,7 @@
3AE5C39B1BFD522300F1080F /* DecoderType.swift */,
3B62AADB1B824C1200491A67 /* JSONCodable.swift */,
3B62AAD81B82452800491A67 /* Defines.swift */,
3AA08DD91BFE417C001BCA4D /* Deprecated.swift */,
3A512EC91BE168C30091A124 /* Configuration */,
);
path = Alexander;
Expand Down Expand Up @@ -550,6 +556,7 @@
files = (
3AE5C39E1BFD522300F1080F /* DecoderType.swift in Sources */,
3A512F051BE16B250091A124 /* JSONCodable.swift in Sources */,
3AA08DDC1BFE417C001BCA4D /* Deprecated.swift in Sources */,
3A512F041BE16B250091A124 /* JSON.swift in Sources */,
3A512F061BE16B250091A124 /* Defines.swift in Sources */,
);
Expand All @@ -570,6 +577,7 @@
files = (
3AE5C39F1BFD522300F1080F /* DecoderType.swift in Sources */,
3A512F081BE16B250091A124 /* JSONCodable.swift in Sources */,
3AA08DDD1BFE417C001BCA4D /* Deprecated.swift in Sources */,
3A512F071BE16B250091A124 /* JSON.swift in Sources */,
3A512F091BE16B250091A124 /* Defines.swift in Sources */,
);
Expand All @@ -581,6 +589,7 @@
files = (
3AE5C39C1BFD522300F1080F /* DecoderType.swift in Sources */,
3B62AAD91B82452800491A67 /* Defines.swift in Sources */,
3AA08DDA1BFE417C001BCA4D /* Deprecated.swift in Sources */,
3B62AADC1B824C1200491A67 /* JSONCodable.swift in Sources */,
3BEDAE5D1B5DC4B200AD52FE /* JSON.swift in Sources */,
);
Expand All @@ -601,6 +610,7 @@
files = (
3AE5C39D1BFD522300F1080F /* DecoderType.swift in Sources */,
3B62AADA1B82452800491A67 /* Defines.swift in Sources */,
3AA08DDB1BFE417C001BCA4D /* Deprecated.swift in Sources */,
3BEDAE7D1B5DC58800AD52FE /* JSON.swift in Sources */,
3A512EC81BE15A380091A124 /* JSONCodable.swift in Sources */,
);
Expand Down
58 changes: 58 additions & 0 deletions Alexander/Deprecated.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Deprecated.swift
// Alexander
//
// Created by Caleb Davenport on 11/19/15.
// Copyright © 2015 Hodinkee. All rights reserved.
//

extension JSON {
@available(*, deprecated, message = "Use stringValue instead.")
public var string: String? {
return stringValue
}

@available(*, deprecated, message = "Use intValue instead.")
public var int: Int? {
return intValue
}

public var double: Double? {
return object as? Double
}

@available(*, deprecated, message = "Use boolValue instead.")
public var bool: Bool? {
return boolValue
}

@available(*, deprecated, message = "Use decode(NSURLDecoder) instead.")
public var url: NSURL? {
return decode(NSURLDecoder)
}

@available(*, deprecated, message = "Use decode(NSTimeIntervalDecoder) instead.")
public var timeInterval: NSTimeInterval? {
return decode(NSTimeIntervalDecoder)
}

@available(*, deprecated, message = "Use decode(NSDateTimeIntervalSince1970Decoder) instead.")
public var date: NSDate? {
return decode(NSDateTimeIntervalSince1970Decoder)
}
}

@available(*, deprecated, message = "Use DecoderType instead.")
public protocol JSONDecodable {
static func decode(JSON: Alexander.JSON) -> Self?
}

public extension Alexander.JSON {
public func decode<T: JSONDecodable>(type: T.Type) -> T? {
return decode(T.decode)
}

public func decodeArray<T: JSONDecodable>(type: T.Type) -> [T]? {
return decodeArray(T.decode)
}
}
36 changes: 0 additions & 36 deletions Alexander/JSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,39 +107,3 @@ extension JSON: CustomDebugStringConvertible {
return "Invalid JSON."
}
}

extension JSON {
@available(*, deprecated, message = "Use stringValue instead.")
public var string: String? {
return stringValue
}

@available(*, deprecated, message = "Use intValue instead.")
public var int: Int? {
return intValue
}

public var double: Double? {
return object as? Double
}

@available(*, deprecated, message = "Use boolValue instead.")
public var bool: Bool? {
return boolValue
}

@available(*, deprecated, message = "Use decode(NSURLDecoder) instead.")
public var url: NSURL? {
return decode(NSURLDecoder)
}

@available(*, deprecated, message = "Use decode(NSTimeIntervalDecoder) instead.")
public var timeInterval: NSTimeInterval? {
return decode(NSTimeIntervalDecoder)
}

@available(*, deprecated, message = "Use decode(NSDateTimeIntervalSince1970Decoder) instead.")
public var date: NSDate? {
return decode(NSDateTimeIntervalSince1970Decoder)
}
}
15 changes: 0 additions & 15 deletions Alexander/JSONCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,3 @@
public protocol JSONEncodable {
var JSON: Alexander.JSON { get }
}

@available(*, deprecated, message = "Use DecoderType instead.")
public protocol JSONDecodable {
static func decode(JSON: Alexander.JSON) -> Self?
}

public extension Alexander.JSON {
public func decode<T: JSONDecodable>(type: T.Type) -> T? {
return decode(T.decode)
}

public func decodeArray<T: JSONDecodable>(type: T.Type) -> [T]? {
return decodeArray(T.decode)
}
}

0 comments on commit 8bef09f

Please sign in to comment.