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

Commit 1c12950

Browse files
committed
More info in README.md and podspec
1 parent 5905124 commit 1c12950

File tree

3 files changed

+82
-8
lines changed

3 files changed

+82
-8
lines changed

Example/ViewController.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ class ViewController: UIViewController {
1515

1616
override func viewDidLoad() {
1717
super.viewDidLoad()
18+
19+
// Asynchronous
20+
net.data(URL(string: "http://www.alexruperez.com/home.json")!).async { (response, error) in
21+
do {
22+
if let object: [AnyHashable: Any] = try response?.object() {
23+
print(type(of: object))
24+
} else if let error = error {
25+
print("Net error: \(error)")
26+
}
27+
} catch {
28+
print("Parse error: \((error as! NetError).localizedDescription)")
29+
}
30+
}
31+
32+
// Synchronous
1833
do {
1934
let date = Date()
2035
let object: [AnyHashable: Any] = try net.data("http://www.alexruperez.com/home.json").sync().object()

NetClient.podspec

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
Pod::Spec.new do |s|
22
s.name = 'NetClient'
33
s.version = '0.1.0'
4-
s.summary = 'A Swift library written in Swift 3'
4+
s.summary = 'Versatile HTTP networking library written in Swift 3.'
55

66
s.homepage = 'https://github.com/intelygenz/NetClient-iOS'
77
s.license = { :type => 'MIT', :file => 'LICENSE' }
88
s.authors = { 'Alex Rupérez' => '[email protected]' }
99
s.source = { :git => 'https://github.com/intelygenz/NetClient-iOS.git', :tag => s.version.to_s }
10-
s.social_media_url = "https://twitter.com/intelygenz"
10+
s.social_media_url = 'https://twitter.com/intelygenz'
11+
s.screenshot = 'https://raw.githubusercontent.com/intelygenz/NetClient-iOS/master/Net.png'
1112

1213
s.ios.deployment_target = '8.0'
1314
s.watchos.deployment_target = '2.0'
1415
s.tvos.deployment_target = '9.0'
1516
s.osx.deployment_target = '10.9'
1617

17-
s.source_files ="Core/*.{h,swift}"
18+
s.framework = 'Foundation'
19+
s.module_name = 'Net'
20+
21+
s.subspec 'Core' do |ss|
22+
ss.source_files = "Core/*.{h,swift}"
23+
end
24+
25+
s.subspec 'URLSession' do |ss|
26+
ss.dependency 'NetClient/Core'
27+
ss.source_files = "URLSession/*.{h,swift}"
28+
end
1829
end
19-

README.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,31 @@
1111

1212
![Net](https://raw.githubusercontent.com/intelygenz/NetClient-iOS/master/Net.png)
1313

14-
**Net** is a Swift library.
14+
**Net** is a versatile HTTP networking library written in Swift 3.
1515

1616
## Features
1717

18-
- [x] watchOS compatible
19-
- [x] tvOS compatible
20-
- [x] macOS compatible
18+
- [x] URL / JSON / Property List Parameter Encoding
19+
- [x] Upload File / Data / Stream / MultipartFormData
20+
- [x] Download File using Request or Resume Data
21+
- [x] Authentication with URLCredential
22+
- [x] Basic, Bearer and Custom Authorization Handling
23+
- [x] Default and Custom Cache Controls
24+
- [x] Default and Custom Content Types
25+
- [x] Upload and Download Progress Closures with Progress
26+
- [x] cURL Command Debug Output
27+
- [x] Request and Response Interceptors
28+
- [x] Asynchronous and synchronous task execution
29+
- [x] Inference of desired response object
30+
- [x] watchOS Compatible
31+
- [x] tvOS Compatible
32+
- [x] macOS Compatible
33+
34+
## Requirements
35+
36+
- iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
37+
- Xcode 8.1+
38+
- Swift 3.0+
2139

2240
## Installation
2341

@@ -44,8 +62,39 @@ dependencies: [
4462

4563
## Usage
4664

65+
Asynchronous:
66+
67+
```swift
68+
import Net
69+
70+
let net = NetURLSession()
71+
72+
net.data(URL(string: "YOUR_URL")!).async { (response, error) in
73+
do {
74+
if let object: [AnyHashable: Any] = try response?.object() {
75+
print("Response dictionary: \(object)")
76+
} else if let error = error {
77+
print("Net error: \(error)")
78+
}
79+
} catch {
80+
print("Parse error: \(error)")
81+
}
82+
}
83+
```
84+
85+
Synchronous:
86+
4787
```swift
88+
import Net
89+
90+
let net = NetURLSession()
4891

92+
do {
93+
let object: [AnyHashable: Any] = try net.data("YOUR_URL").sync().object()
94+
print("Response dictionary: \(object)")
95+
} catch {
96+
print("Error: \(error)")
97+
}
4998
```
5099

51100
## Etc.

0 commit comments

Comments
 (0)