Permalink
Browse files

Update NSURL in docs (#656)

  • Loading branch information...
zlangley authored and mxcl committed May 17, 2017
1 parent 9b67f14 commit c3be8eb7ef3765bc4e8ec8c82eb0d97e41e4bf35
Showing with 20 additions and 20 deletions.
  1. +1 −1 README.zh_CN.md
  2. +1 −1 README.zh_Hant.md
  3. +1 −1 Sources/Error.swift
  4. +1 −1 Sources/Promise+AnyPromise.swift
  5. +14 −14 Sources/Promise.swift
  6. +2 −2 Sources/when.swift
View
@@ -183,7 +183,7 @@ github "PromiseKit/MapKit" ~> 1.0
## 选择网络库
直接使用 `NSURLSession` 通常是不可取的,您可以选择使用 [Alamofire] or [OMGHTTPURLRQ]:
直接使用 `URLSession` 通常是不可取的,您可以选择使用 [Alamofire] or [OMGHTTPURLRQ]:
```swift
// pod 'PromiseKit/Alamofire'
View
@@ -181,7 +181,7 @@ github "PromiseKit/MapKit" ~> 1.0
## 選擇使用網路相關函式庫
`NSURLSession` 一般來說很難勝任複雜的網路存取相關任務; 建議使用 [Alamofire] 或者 [OMGHTTPURLRQ]:
`URLSession` 一般來說很難勝任複雜的網路存取相關任務; 建議使用 [Alamofire] 或者 [OMGHTTPURLRQ]:
```swift
// pod 'PromiseKit/Alamofire'
View
@@ -46,7 +46,7 @@ public enum PMKURLError: Error {
case stringEncoding(URLRequest, Data, URLResponse)
/**
Usually the `NSURLResponse` is actually an `NSHTTPURLResponse`, if so you
Usually the `URLResponse` is actually an `HTTPURLResponse`, if so you
can access it using this property. Since it is returned as an unwrapped
optional: be sure.
*/
@@ -8,7 +8,7 @@ extension Promise {
- Parameter body: The closure that is executed when this promise fulfills.
- Returns: A new promise that resolves when the `AnyPromise` returned from the provided closure resolves. For example:
NSURLSession.GET(url).then { (data: NSData) -> AnyPromise in
URLSession.GET(url).then { (data: NSData) -> AnyPromise in
//…
return SCNetworkReachability()
}.then { _ in
View
@@ -139,7 +139,7 @@ open class Promise<T> {
- Parameter body: The closure that is executed when this Promise is fulfilled.
- Returns: A new promise that is resolved with the value returned from the provided closure. For example:
NSURLSession.GET(url).then { data -> Int in
URLSession.GET(url).then { data -> Int in
//…
return data.length
}.then { length in
@@ -330,7 +330,7 @@ open class Promise<T> {
The function you provide cannot mutate the chain.
NSURLSession.GET(/*…*/).tap { result in
URLSession.GET(/*…*/).tap { result in
print(result)
}
@@ -422,20 +422,20 @@ extension Promise: CustomStringConvertible {
Compare:
NSURLSession.GET(url1).then {
NSURLSession.GET(url2)
URLSession.GET(url1).then {
URLSession.GET(url2)
}.then {
NSURLSession.GET(url3)
URLSession.GET(url3)
}
With:
firstly {
NSURLSession.GET(url1)
URLSession.GET(url1)
}.then {
NSURLSession.GET(url2)
URLSession.GET(url2)
}.then {
NSURLSession.GET(url3)
URLSession.GET(url3)
}
*/
public func firstly<T>(execute body: () throws -> Promise<T>) -> Promise<T> {
@@ -448,20 +448,20 @@ public func firstly<T>(execute body: () throws -> Promise<T>) -> Promise<T> {
Compare:
when(fulfilled: NSURLSession.GET(url1), NSURLSession.GET(url2)).then {
NSURLSession.GET(url3)
when(fulfilled: URLSession.GET(url1), URLSession.GET(url2)).then {
URLSession.GET(url3)
}.then {
NSURLSession.GET(url4)
URLSession.GET(url4)
}
With:
firstly {
(NSURLSession.GET(url1), NSURLSession.GET(url2))
(URLSession.GET(url1), URLSession.GET(url2))
}.then { _, _ in
NSURLSession.GET(url2)
URLSession.GET(url2)
}.then {
NSURLSession.GET(url3)
URLSession.GET(url3)
}
- Note: At maximum 5 promises may be returned in a tuple
View
@@ -53,9 +53,9 @@ private func _when<T>(_ promises: [Promise<T>]) -> Promise<Void> {
//…
}.catch { error in
switch error {
case NSURLError.NoConnection:
case URLError.notConnectedToInternet:
//…
case CLError.NotAuthorized:
case CLError.denied:
//…
}
}

0 comments on commit c3be8eb

Please sign in to comment.