Skip to content

Commit e154f30

Browse files
authored
Merge pull request #44 from SomaticLabs/device-names
Moment and Zorb in deviceNames
2 parents 33fdae9 + f994390 commit e154f30

File tree

23 files changed

+315
-69
lines changed

23 files changed

+315
-69
lines changed

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
github "Alamofire/Alamofire" "4.6.0"
1+
github "Alamofire/Alamofire" "4.7.3"
2+
github "SwiftyJSON/SwiftyJSON" "4.1.0"
23
github "jordanebelanger/SwiftyBluetooth" "1.0.0"
3-
github "SwiftyJSON/SwiftyJSON" "4.0.0"

Carthage/Checkouts/Alamofire

Submodule Alamofire updated 192 files
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: objective-c
2-
osx_image: xcode9
2+
osx_image: xcode9.3
33
xcode_sdk: iphonesimulator10.0
44
script:
55
- set -o pipefail
66
- travis_retry xcodebuild -workspace SwiftyJSON.xcworkspace -scheme "SwiftyJSON iOS" -destination "platform=iOS Simulator,name=iPhone 6" build-for-testing test | xcpretty
77
- travis_retry xcodebuild -workspace SwiftyJSON.xcworkspace -scheme "SwiftyJSON macOS" build-for-testing test | xcpretty
8-
- travis_retry xcodebuild -workspace SwiftyJSON.xcworkspace -scheme "SwiftyJSON tvOS" -destination "platform=tvOS Simulator,name=Apple TV 1080p" build-for-testing test | xcpretty
8+
- travis_retry xcodebuild -workspace SwiftyJSON.xcworkspace -scheme "SwiftyJSON tvOS" -destination "platform=tvOS Simulator,name=Apple TV" build-for-testing test | xcpretty

Carthage/Checkouts/SwiftyJSON/Example/Example.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
isa = PBXProject;
125125
attributes = {
126126
LastSwiftUpdateCheck = 0700;
127-
LastUpgradeCheck = 0900;
127+
LastUpgradeCheck = 0930;
128128
ORGANIZATIONNAME = swiftyjson;
129129
TargetAttributes = {
130130
A82A1C1819D926B8009A653D = {
@@ -210,12 +210,14 @@
210210
CLANG_WARN_BOOL_CONVERSION = YES;
211211
CLANG_WARN_COMMA = YES;
212212
CLANG_WARN_CONSTANT_CONVERSION = YES;
213+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
213214
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
214215
CLANG_WARN_EMPTY_BODY = YES;
215216
CLANG_WARN_ENUM_CONVERSION = YES;
216217
CLANG_WARN_INFINITE_RECURSION = YES;
217218
CLANG_WARN_INT_CONVERSION = YES;
218219
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
220+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
219221
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
220222
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
221223
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
@@ -264,12 +266,14 @@
264266
CLANG_WARN_BOOL_CONVERSION = YES;
265267
CLANG_WARN_COMMA = YES;
266268
CLANG_WARN_CONSTANT_CONVERSION = YES;
269+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
267270
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
268271
CLANG_WARN_EMPTY_BODY = YES;
269272
CLANG_WARN_ENUM_CONVERSION = YES;
270273
CLANG_WARN_INFINITE_RECURSION = YES;
271274
CLANG_WARN_INT_CONVERSION = YES;
272275
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
276+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
273277
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
274278
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
275279
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;

Carthage/Checkouts/SwiftyJSON/Example/Playground.playground/Contents.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,3 @@ let stringRepresentionJson: JSON = JSON(stringRepresentationDict)
413413
let representation = stringRepresentionJson.rawString([.castNilToNSNull: true])
414414
print(representation!)
415415
// representation is "{\"1\":2,\"2\":\"two\",\"3\":null}", which represents {"1":2,"2":"two","3":null}
416-

Carthage/Checkouts/SwiftyJSON/README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ SwiftyJSON makes it easy to deal with JSON data in Swift.
2121
5. [Work with Alamofire](#work-with-alamofire)
2222
6. [Work with Moya](#work-with-moya)
2323

24-
> For Legacy Swift support, take a look at the [swift2 branch](https://github.com/SwiftyJSON/SwiftyJSON/tree/swift2)
25-
2624
> [中文介绍](http://tangplin.github.io/swiftyjson/)
2725
2826

2927
## Why is the typical JSON handling in Swift NOT good?
3028

3129
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.
3230

33-
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://dev.twitter.com/docs/api/1.1/get/statuses/home_timeline).
31+
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)).
3432

3533
The code would look like this:
3634

@@ -92,38 +90,36 @@ platform :ios, '8.0'
9290
use_frameworks!
9391

9492
target 'MyApp' do
95-
pod 'SwiftyJSON'
93+
pod 'SwiftyJSON', '~> 4.0'
9694
end
9795
```
9896

99-
Note that this requires CocoaPods version 36, and your iOS deployment target to be at least 8.0:
100-
101-
10297
#### Carthage (iOS 8+, OS X 10.9+)
10398

10499
You can use [Carthage](https://github.com/Carthage/Carthage) to install `SwiftyJSON` by adding it to your `Cartfile`:
105100

106101
```
107-
github "SwiftyJSON/SwiftyJSON"
102+
github "SwiftyJSON/SwiftyJSON" ~> 4.0
108103
```
109104

105+
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.
106+
110107
#### Swift Package Manager
111108

112109
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:
113110

114111
```swift
112+
// swift-tools-version:4.0
115113
import PackageDescription
116114

117115
let package = Package(
118116
name: "YOUR_PROJECT_NAME",
119-
targets: [],
120117
dependencies: [
121-
.Package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", versions: Version(1, 0, 0)..<Version(3, .max, .max)),
118+
.package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"),
122119
]
123120
)
124121
```
125-
126-
Note that the [Swift Package Manager](https://swift.org/package-manager) is still in early design and development, for more information checkout its [GitHub Page](https://github.com/apple/swift-package-manager)
122+
Then run `swift build` whenever you get prepared.
127123

128124
#### Manually (iOS 7+, OS X 10.9+)
129125

@@ -190,7 +186,7 @@ let name = json[].string
190186

191187
```swift
192188
// With a custom way
193-
let keys:[SubscriptType] = [1,"list",2,"name"]
189+
let keys:[JSONSubscriptType] = [1,"list",2,"name"]
194190
let name = json[keys].string
195191
```
196192

Carthage/Checkouts/SwiftyJSON/Source/SwiftyJSON.swift

Lines changed: 120 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -545,53 +545,50 @@ extension JSON {
545545
extension JSON: Swift.ExpressibleByStringLiteral {
546546

547547
public init(stringLiteral value: StringLiteralType) {
548-
self.init(value as Any)
548+
self.init(value)
549549
}
550550

551551
public init(extendedGraphemeClusterLiteral value: StringLiteralType) {
552-
self.init(value as Any)
552+
self.init(value)
553553
}
554554

555555
public init(unicodeScalarLiteral value: StringLiteralType) {
556-
self.init(value as Any)
556+
self.init(value)
557557
}
558558
}
559559

560560
extension JSON: Swift.ExpressibleByIntegerLiteral {
561561

562562
public init(integerLiteral value: IntegerLiteralType) {
563-
self.init(value as Any)
563+
self.init(value)
564564
}
565565
}
566566

567567
extension JSON: Swift.ExpressibleByBooleanLiteral {
568568

569569
public init(booleanLiteral value: BooleanLiteralType) {
570-
self.init(value as Any)
570+
self.init(value)
571571
}
572572
}
573573

574574
extension JSON: Swift.ExpressibleByFloatLiteral {
575575

576576
public init(floatLiteral value: FloatLiteralType) {
577-
self.init(value as Any)
577+
self.init(value)
578578
}
579579
}
580580

581581
extension JSON: Swift.ExpressibleByDictionaryLiteral {
582582
public init(dictionaryLiteral elements: (String, Any)...) {
583-
var dictionary = [String: Any](minimumCapacity: elements.count)
584-
for (k, v) in elements {
585-
dictionary[k] = v
586-
}
587-
self.init(dictionary as Any)
583+
let dictionary = elements.reduce(into: [String: Any](), { $0[$1.0] = $1.1})
584+
self.init(dictionary)
588585
}
589586
}
590587

591588
extension JSON: Swift.ExpressibleByArrayLiteral {
592589

593590
public init(arrayLiteral elements: Any...) {
594-
self.init(elements as Any)
591+
self.init(elements)
595592
}
596593
}
597594

@@ -776,7 +773,7 @@ extension JSON {
776773
}
777774
set {
778775
if let array = newValue {
779-
self.object = array as Any
776+
self.object = array
780777
} else {
781778
self.object = NSNull()
782779
}
@@ -819,7 +816,7 @@ extension JSON {
819816
}
820817
set {
821818
if let v = newValue {
822-
self.object = v as Any
819+
self.object = v
823820
} else {
824821
self.object = NSNull()
825822
}
@@ -1455,3 +1452,112 @@ public enum writingOptionsKeys {
14551452
case maxObjextDepth
14561453
case encoding
14571454
}
1455+
1456+
// MARK: - JSON: Codable
1457+
extension JSON: Codable {
1458+
private static var codableTypes: [Codable.Type] {
1459+
return [
1460+
Bool.self,
1461+
Int.self,
1462+
Int8.self,
1463+
Int16.self,
1464+
Int32.self,
1465+
Int64.self,
1466+
UInt.self,
1467+
UInt8.self,
1468+
UInt16.self,
1469+
UInt32.self,
1470+
UInt64.self,
1471+
Double.self,
1472+
String.self,
1473+
[JSON].self,
1474+
[String: JSON].self
1475+
]
1476+
}
1477+
public init(from decoder: Decoder) throws {
1478+
var object: Any?
1479+
1480+
if let container = try? decoder.singleValueContainer(), !container.decodeNil() {
1481+
for type in JSON.codableTypes {
1482+
if object != nil {
1483+
break
1484+
}
1485+
// try to decode value
1486+
switch type {
1487+
case let boolType as Bool.Type:
1488+
object = try? container.decode(boolType)
1489+
case let intType as Int.Type:
1490+
object = try? container.decode(intType)
1491+
case let int8Type as Int8.Type:
1492+
object = try? container.decode(int8Type)
1493+
case let int32Type as Int32.Type:
1494+
object = try? container.decode(int32Type)
1495+
case let int64Type as Int64.Type:
1496+
object = try? container.decode(int64Type)
1497+
case let uintType as UInt.Type:
1498+
object = try? container.decode(uintType)
1499+
case let uint8Type as UInt8.Type:
1500+
object = try? container.decode(uint8Type)
1501+
case let uint16Type as UInt16.Type:
1502+
object = try? container.decode(uint16Type)
1503+
case let uint32Type as UInt32.Type:
1504+
object = try? container.decode(uint32Type)
1505+
case let uint64Type as UInt64.Type:
1506+
object = try? container.decode(uint64Type)
1507+
case let doubleType as Double.Type:
1508+
object = try? container.decode(doubleType)
1509+
case let stringType as String.Type:
1510+
object = try? container.decode(stringType)
1511+
case let jsonValueArrayType as [JSON].Type:
1512+
object = try? container.decode(jsonValueArrayType)
1513+
case let jsonValueDictType as [String: JSON].Type:
1514+
object = try? container.decode(jsonValueDictType)
1515+
default:
1516+
break
1517+
}
1518+
}
1519+
}
1520+
self.init(object ?? NSNull())
1521+
}
1522+
public func encode(to encoder: Encoder) throws {
1523+
var container = encoder.singleValueContainer()
1524+
if object is NSNull {
1525+
try container.encodeNil()
1526+
return
1527+
}
1528+
switch object {
1529+
case let intValue as Int:
1530+
try container.encode(intValue)
1531+
case let int8Value as Int8:
1532+
try container.encode(int8Value)
1533+
case let int32Value as Int32:
1534+
try container.encode(int32Value)
1535+
case let int64Value as Int64:
1536+
try container.encode(int64Value)
1537+
case let uintValue as UInt:
1538+
try container.encode(uintValue)
1539+
case let uint8Value as UInt8:
1540+
try container.encode(uint8Value)
1541+
case let uint16Value as UInt16:
1542+
try container.encode(uint16Value)
1543+
case let uint32Value as UInt32:
1544+
try container.encode(uint32Value)
1545+
case let uint64Value as UInt64:
1546+
try container.encode(uint64Value)
1547+
case let doubleValue as Double:
1548+
try container.encode(doubleValue)
1549+
case let boolValue as Bool:
1550+
try container.encode(boolValue)
1551+
case let stringValue as String:
1552+
try container.encode(stringValue)
1553+
case is [Any]:
1554+
let jsonValueArray = array ?? []
1555+
try container.encode(jsonValueArray)
1556+
case is [String: Any]:
1557+
let jsonValueDictValue = dictionary ?? [:]
1558+
try container.encode(jsonValueDictValue)
1559+
default:
1560+
break
1561+
}
1562+
}
1563+
}

Carthage/Checkouts/SwiftyJSON/SwiftyJSON.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "SwiftyJSON"
3-
s.version = "4.0.0"
3+
s.version = "4.1.0"
44
s.summary = "SwiftyJSON makes it easy to deal with JSON data in Swift"
55
s.homepage = "https://github.com/SwiftyJSON/SwiftyJSON"
66
s.license = { :type => "MIT" }

0 commit comments

Comments
 (0)