Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Commit 6de885c

Browse files
committed
Release 0.3.4 Kommander update and fix
1 parent d0c9051 commit 6de885c

File tree

27 files changed

+1306
-1219
lines changed

27 files changed

+1306
-1219
lines changed

Alamofire/NetAlamofire.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Alamofire
1010

1111
public class NetAlamofire: Net {
1212

13-
open static let shared: Net = NetAlamofire()
13+
open static let shared: Net = NetAlamofire(URLSession.shared)!
1414

1515
open static let defaultCache: URLCache = {
1616
let defaultMemoryCapacity = 4 * 1024 * 1024

Core/NetAuthorization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extension NetAuthorization: RawRepresentable {
3535
}
3636
} else if rawValue.hasPrefix(StringValue.bearer) {
3737
self = .bearer(token: "\(rawValue[StringValue.bearer.endIndex...])")
38-
} else if rawValue.characters.count > 0 {
38+
} else if rawValue.count > 0 {
3939
self = .custom(rawValue)
4040
}
4141
}

Core/NetCacheControl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extension NetCacheControl: RawRepresentable {
3232
if rawValue.hasPrefix(StringValue.maxAge), let timeInterval = TimeInterval(rawValue[rawValue.index(StringValue.maxAge.endIndex, offsetBy: 1)...]) {
3333
self = .maxAge(timeInterval)
3434
} else if rawValue.hasPrefix(StringValue.maxStale) {
35-
if rawValue.characters.count > StringValue.maxStale.characters.count + 1 {
35+
if rawValue.count > StringValue.maxStale.count + 1 {
3636
self = .maxStale(TimeInterval(rawValue[rawValue.index(StringValue.maxStale.endIndex, offsetBy: 1)...]))
3737
} else {
3838
self = .maxStale(nil)

Core/NetResponse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ extension NetResponse: CustomStringConvertible {
100100
description = description + statusCode
101101
}
102102
if let url = url?.description {
103-
if description.characters.count > 0 {
103+
if description.count > 0 {
104104
description = description + " "
105105
}
106106
description = description + url
107107
}
108108
if let localizedDescription = localizedDescription?.description {
109-
if description.characters.count > 0 {
109+
if description.count > 0 {
110110
description = description + " "
111111
}
112112
description = description + "(\(localizedDescription))"

Example/ViewController.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
import UIKit
1010
import Net
1111
import Moya
12+
import Kommander
1213

1314
class ViewController: UIViewController {
1415

15-
let net: Net = NetURLSession()
16+
let net: Net = NetURLSession.shared
17+
let kommander: Kommander = .default
1618

1719
override func viewDidLoad() {
1820
super.viewDidLoad()
@@ -28,7 +30,7 @@ class ViewController: UIViewController {
2830
print("Net error: \(error)")
2931
}
3032
} catch {
31-
print("Parse error: \((error as! NetError).localizedDescription)")
33+
print("Parse error: \(error.localizedDescription)")
3234
}
3335
}
3436

@@ -39,7 +41,7 @@ class ViewController: UIViewController {
3941
print(type(of: object))
4042
print("Time: \(Date().timeIntervalSince(date))")
4143
} catch {
42-
print("Error: \((error as! NetError).localizedDescription)")
44+
print("Error: \(error.localizedDescription)")
4345
}
4446

4547
// Moya
@@ -54,16 +56,16 @@ class ViewController: UIViewController {
5456
}
5557

5658
// Kommander
57-
net.data(request).execute(onSuccess: { object in
59+
net.data(request).execute(by: kommander, onSuccess: { object in
5860
print(object)
5961
}) { error in
60-
print("Error: \((error as! NetError).localizedDescription)")
62+
print("Error: \(String(describing: error?.localizedDescription))")
6163
}
6264

63-
net.data(request).executeDecoding(onSuccess: { object in
65+
net.data(request).executeDecoding(by: kommander, onSuccess: { object in
6466
print(object as Article)
6567
}) { error in
66-
print("Error: \((error as! NetError).localizedDescription)")
68+
print("Error: \(String(describing: error?.localizedDescription))")
6769
}
6870

6971
// Decode
@@ -77,7 +79,7 @@ class ViewController: UIViewController {
7779
print("Net error: \(error)")
7880
}
7981
} catch {
80-
print("Parse error: \((error as! NetError).localizedDescription)")
82+
print("Parse error: \(error.localizedDescription)")
8183
}
8284
}
8385

Kommander/NetTask+Kommander.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Kommander
1111
extension NetTask {
1212

1313
/// Execute NetTask
14-
@discardableResult open func execute<T>(by kommander: Kommander = .default, after delay: DispatchTimeInterval? = nil, onSuccess: ((_ result: T) -> Void)?, onError: ((_ error: Error?) -> Void)?) -> Kommand<T> {
14+
@discardableResult open func execute<T>(by kommander: Kommander, after delay: DispatchTimeInterval? = nil, onSuccess: ((_ result: T) -> Void)?, onError: ((_ error: Error?) -> Void)?) -> Kommand<T> {
1515
let kommand = kommander.makeKommand {
1616
return try self.sync().object()
1717
}.onSuccess { result in
@@ -28,7 +28,7 @@ extension NetTask {
2828
}
2929

3030
/// Execute NetTask decoding the result
31-
@discardableResult open func executeDecoding<T: Decodable>(by kommander: Kommander = .default, after delay: DispatchTimeInterval? = nil, onSuccess: ((_ result: T) -> Void)?, onError: ((_ error: Error?) -> Void)?) -> Kommand<T> {
31+
@discardableResult open func executeDecoding<T: Decodable>(by kommander: Kommander, after delay: DispatchTimeInterval? = nil, onSuccess: ((_ result: T) -> Void)?, onError: ((_ error: Error?) -> Void)?) -> Kommand<T> {
3232
let kommand = kommander.makeKommand {
3333
return try self.sync().decode()
3434
}.onSuccess { result in

Net.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@
769769
isa = PBXProject;
770770
attributes = {
771771
LastSwiftUpdateCheck = 0820;
772-
LastUpgradeCheck = 0900;
772+
LastUpgradeCheck = 0910;
773773
TargetAttributes = {
774774
D5A521611E7B340D00406F0F = {
775775
CreatedOnToolsVersion = 8.2.1;

Net.xcodeproj/xcshareddata/xcschemes/Core.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Net.xcodeproj/xcshareddata/xcschemes/Example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Net.xcodeproj/xcshareddata/xcschemes/iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0900"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

0 commit comments

Comments
 (0)