Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
3d534c3b
Commit
3d534c3b
authored
Apr 01, 2016
by
Ben Asher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Alamofire example for Xcode 7.3
parent
8e2f0ef7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
110 additions
and
36 deletions
+110
-36
Alamofire.podspec
examples/Alamofire Example/Alamofire/Alamofire.podspec
+1
-1
Manager.swift
examples/Alamofire Example/Alamofire/Source/Manager.swift
+76
-18
MultipartFormData.swift
...lamofire Example/Alamofire/Source/MultipartFormData.swift
+0
-6
NetworkReachabilityManager.swift
...Example/Alamofire/Source/NetworkReachabilityManager.swift
+13
-1
ParameterEncoding.swift
...lamofire Example/Alamofire/Source/ParameterEncoding.swift
+1
-1
Request.swift
examples/Alamofire Example/Alamofire/Source/Request.swift
+1
-1
ResponseSerialization.swift
...fire Example/Alamofire/Source/ResponseSerialization.swift
+17
-7
DetailViewController.swift
...ples/Alamofire Example/Example/DetailViewController.swift
+1
-1
No files found.
examples/Alamofire Example/Alamofire/Alamofire.podspec
View file @
3d534c3b
Pod
::
Spec
.
new
do
|
s
|
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'Alamofire'
s
.
name
=
'Alamofire'
s
.
version
=
'3.
2.1
'
s
.
version
=
'3.
3.0
'
s
.
license
=
'MIT'
s
.
license
=
'MIT'
s
.
summary
=
'Elegant HTTP Networking in Swift'
s
.
summary
=
'Elegant HTTP Networking in Swift'
s
.
homepage
=
'https://github.com/Alamofire/Alamofire'
s
.
homepage
=
'https://github.com/Alamofire/Alamofire'
...
...
examples/Alamofire Example/Alamofire/Source/Manager.swift
View file @
3d534c3b
...
@@ -56,10 +56,10 @@ public class Manager {
...
@@ -56,10 +56,10 @@ public class Manager {
// User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3
// User-Agent Header; see https://tools.ietf.org/html/rfc7231#section-5.5.3
let
userAgent
:
String
=
{
let
userAgent
:
String
=
{
if
let
info
=
NSBundle
.
mainBundle
()
.
infoDictionary
{
if
let
info
=
NSBundle
.
mainBundle
()
.
infoDictionary
{
let
executable
:
AnyObject
=
info
[
kCFBundleExecutableKey
as
String
]
??
"Unknown"
let
executable
=
info
[
kCFBundleExecutableKey
as
String
]
as?
String
??
"Unknown"
let
bundle
:
AnyObject
=
info
[
kCFBundleIdentifierKey
as
String
]
??
"Unknown"
let
bundle
=
info
[
kCFBundleIdentifierKey
as
String
]
as?
String
??
"Unknown"
let
version
:
AnyObject
=
info
[
kCFBundleVersionKey
as
String
]
??
"Unknown"
let
version
=
info
[
kCFBundleVersionKey
as
String
]
as?
String
??
"Unknown"
let
os
:
AnyObject
=
NSProcessInfo
.
processInfo
()
.
operatingSystemVersionString
??
"Unknown"
let
os
=
NSProcessInfo
.
processInfo
()
.
operatingSystemVersionString
var
mutableUserAgent
=
NSMutableString
(
string
:
"
\(
executable
)
/
\(
bundle
)
(
\(
version
)
; OS
\(
os
)
)"
)
as
CFMutableString
var
mutableUserAgent
=
NSMutableString
(
string
:
"
\(
executable
)
/
\(
bundle
)
(
\(
version
)
; OS
\(
os
)
)"
)
as
CFMutableString
let
transform
=
NSString
(
string
:
"Any-Latin; Latin-ASCII; [:^ASCII:] Remove"
)
as
CFString
let
transform
=
NSString
(
string
:
"Any-Latin; Latin-ASCII; [:^ASCII:] Remove"
)
as
CFString
...
@@ -254,6 +254,9 @@ public class Manager {
...
@@ -254,6 +254,9 @@ public class Manager {
/// Overrides default behavior for NSURLSessionDelegate method `URLSession:didReceiveChallenge:completionHandler:`.
/// Overrides default behavior for NSURLSessionDelegate method `URLSession:didReceiveChallenge:completionHandler:`.
public
var
sessionDidReceiveChallenge
:
((
NSURLSession
,
NSURLAuthenticationChallenge
)
->
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?))?
public
var
sessionDidReceiveChallenge
:
((
NSURLSession
,
NSURLAuthenticationChallenge
)
->
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?))?
/// Overrides all behavior for NSURLSessionDelegate method `URLSession:didReceiveChallenge:completionHandler:` and requires the caller to call the `completionHandler`.
public
var
sessionDidReceiveChallengeWithCompletion
:
((
NSURLSession
,
NSURLAuthenticationChallenge
,
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?)
->
Void
)
->
Void
)?
/// Overrides default behavior for NSURLSessionDelegate method `URLSessionDidFinishEventsForBackgroundURLSession:`.
/// Overrides default behavior for NSURLSessionDelegate method `URLSessionDidFinishEventsForBackgroundURLSession:`.
public
var
sessionDidFinishEventsForBackgroundURLSession
:
((
NSURLSession
)
->
Void
)?
public
var
sessionDidFinishEventsForBackgroundURLSession
:
((
NSURLSession
)
->
Void
)?
...
@@ -281,6 +284,11 @@ public class Manager {
...
@@ -281,6 +284,11 @@ public class Manager {
didReceiveChallenge
challenge
:
NSURLAuthenticationChallenge
,
didReceiveChallenge
challenge
:
NSURLAuthenticationChallenge
,
completionHandler
:
((
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?)
->
Void
))
completionHandler
:
((
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?)
->
Void
))
{
{
guard
sessionDidReceiveChallengeWithCompletion
==
nil
else
{
sessionDidReceiveChallengeWithCompletion
?(
session
,
challenge
,
completionHandler
)
return
}
var
disposition
:
NSURLSessionAuthChallengeDisposition
=
.
PerformDefaultHandling
var
disposition
:
NSURLSessionAuthChallengeDisposition
=
.
PerformDefaultHandling
var
credential
:
NSURLCredential
?
var
credential
:
NSURLCredential
?
...
@@ -321,11 +329,23 @@ public class Manager {
...
@@ -321,11 +329,23 @@ public class Manager {
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:`.
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:`.
public
var
taskWillPerformHTTPRedirection
:
((
NSURLSession
,
NSURLSessionTask
,
NSHTTPURLResponse
,
NSURLRequest
)
->
NSURLRequest
?)?
public
var
taskWillPerformHTTPRedirection
:
((
NSURLSession
,
NSURLSessionTask
,
NSHTTPURLResponse
,
NSURLRequest
)
->
NSURLRequest
?)?
/// Overrides all behavior for NSURLSessionTaskDelegate method `URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:` and
/// requires the caller to call the `completionHandler`.
public
var
taskWillPerformHTTPRedirectionWithCompletion
:
((
NSURLSession
,
NSURLSessionTask
,
NSHTTPURLResponse
,
NSURLRequest
,
NSURLRequest
?
->
Void
)
->
Void
)?
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didReceiveChallenge:completionHandler:`.
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didReceiveChallenge:completionHandler:`.
public
var
taskDidReceiveChallenge
:
((
NSURLSession
,
NSURLSessionTask
,
NSURLAuthenticationChallenge
)
->
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?))?
public
var
taskDidReceiveChallenge
:
((
NSURLSession
,
NSURLSessionTask
,
NSURLAuthenticationChallenge
)
->
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?))?
/// Overrides all behavior for NSURLSessionTaskDelegate method `URLSession:task:didReceiveChallenge:completionHandler:` and
/// requires the caller to call the `completionHandler`.
public
var
taskDidReceiveChallengeWithCompletion
:
((
NSURLSession
,
NSURLSessionTask
,
NSURLAuthenticationChallenge
,
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?)
->
Void
)
->
Void
)?
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:session:task:needNewBodyStream:`.
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:session:task:needNewBodyStream:`.
public
var
taskNeedNewBodyStream
:
((
NSURLSession
,
NSURLSessionTask
)
->
NSInputStream
!
)?
public
var
taskNeedNewBodyStream
:
((
NSURLSession
,
NSURLSessionTask
)
->
NSInputStream
?)?
/// Overrides all behavior for NSURLSessionTaskDelegate method `URLSession:session:task:needNewBodyStream:` and
/// requires the caller to call the `completionHandler`.
public
var
taskNeedNewBodyStreamWithCompletion
:
((
NSURLSession
,
NSURLSessionTask
,
NSInputStream
?
->
Void
)
->
Void
)?
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`.
/// Overrides default behavior for NSURLSessionTaskDelegate method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`.
public
var
taskDidSendBodyData
:
((
NSURLSession
,
NSURLSessionTask
,
Int64
,
Int64
,
Int64
)
->
Void
)?
public
var
taskDidSendBodyData
:
((
NSURLSession
,
NSURLSessionTask
,
Int64
,
Int64
,
Int64
)
->
Void
)?
...
@@ -351,8 +371,13 @@ public class Manager {
...
@@ -351,8 +371,13 @@ public class Manager {
task
:
NSURLSessionTask
,
task
:
NSURLSessionTask
,
willPerformHTTPRedirection
response
:
NSHTTPURLResponse
,
willPerformHTTPRedirection
response
:
NSHTTPURLResponse
,
newRequest
request
:
NSURLRequest
,
newRequest
request
:
NSURLRequest
,
completionHandler
:
((
NSURLRequest
?)
->
Void
)
)
completionHandler
:
NSURLRequest
?
->
Void
)
{
{
guard
taskWillPerformHTTPRedirectionWithCompletion
==
nil
else
{
taskWillPerformHTTPRedirectionWithCompletion
?(
session
,
task
,
response
,
request
,
completionHandler
)
return
}
var
redirectRequest
:
NSURLRequest
?
=
request
var
redirectRequest
:
NSURLRequest
?
=
request
if
let
taskWillPerformHTTPRedirection
=
taskWillPerformHTTPRedirection
{
if
let
taskWillPerformHTTPRedirection
=
taskWillPerformHTTPRedirection
{
...
@@ -374,10 +399,16 @@ public class Manager {
...
@@ -374,10 +399,16 @@ public class Manager {
session
:
NSURLSession
,
session
:
NSURLSession
,
task
:
NSURLSessionTask
,
task
:
NSURLSessionTask
,
didReceiveChallenge
challenge
:
NSURLAuthenticationChallenge
,
didReceiveChallenge
challenge
:
NSURLAuthenticationChallenge
,
completionHandler
:
(
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?)
->
Void
)
)
completionHandler
:
(
NSURLSessionAuthChallengeDisposition
,
NSURLCredential
?)
->
Void
)
{
{
guard
taskDidReceiveChallengeWithCompletion
==
nil
else
{
taskDidReceiveChallengeWithCompletion
?(
session
,
task
,
challenge
,
completionHandler
)
return
}
if
let
taskDidReceiveChallenge
=
taskDidReceiveChallenge
{
if
let
taskDidReceiveChallenge
=
taskDidReceiveChallenge
{
completionHandler
(
taskDidReceiveChallenge
(
session
,
task
,
challenge
))
let
result
=
taskDidReceiveChallenge
(
session
,
task
,
challenge
)
completionHandler
(
result
.
0
,
result
.
1
)
}
else
if
let
delegate
=
self
[
task
]
{
}
else
if
let
delegate
=
self
[
task
]
{
delegate
.
URLSession
(
delegate
.
URLSession
(
session
,
session
,
...
@@ -400,8 +431,13 @@ public class Manager {
...
@@ -400,8 +431,13 @@ public class Manager {
public
func
URLSession
(
public
func
URLSession
(
session
:
NSURLSession
,
session
:
NSURLSession
,
task
:
NSURLSessionTask
,
task
:
NSURLSessionTask
,
needNewBodyStream
completionHandler
:
((
NSInputStream
?)
->
Void
)
)
needNewBodyStream
completionHandler
:
NSInputStream
?
->
Void
)
{
{
guard
taskNeedNewBodyStreamWithCompletion
==
nil
else
{
taskNeedNewBodyStreamWithCompletion
?(
session
,
task
,
completionHandler
)
return
}
if
let
taskNeedNewBodyStream
=
taskNeedNewBodyStream
{
if
let
taskNeedNewBodyStream
=
taskNeedNewBodyStream
{
completionHandler
(
taskNeedNewBodyStream
(
session
,
task
))
completionHandler
(
taskNeedNewBodyStream
(
session
,
task
))
}
else
if
let
delegate
=
self
[
task
]
{
}
else
if
let
delegate
=
self
[
task
]
{
...
@@ -464,6 +500,10 @@ public class Manager {
...
@@ -464,6 +500,10 @@ public class Manager {
/// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
/// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didReceiveResponse:completionHandler:`.
public
var
dataTaskDidReceiveResponse
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSURLResponse
)
->
NSURLSessionResponseDisposition
)?
public
var
dataTaskDidReceiveResponse
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSURLResponse
)
->
NSURLSessionResponseDisposition
)?
/// Overrides all behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didReceiveResponse:completionHandler:` and
/// requires caller to call the `completionHandler`.
public
var
dataTaskDidReceiveResponseWithCompletion
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSURLResponse
,
NSURLSessionResponseDisposition
->
Void
)
->
Void
)?
/// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didBecomeDownloadTask:`.
/// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:didBecomeDownloadTask:`.
public
var
dataTaskDidBecomeDownloadTask
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSURLSessionDownloadTask
)
->
Void
)?
public
var
dataTaskDidBecomeDownloadTask
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSURLSessionDownloadTask
)
->
Void
)?
...
@@ -471,7 +511,11 @@ public class Manager {
...
@@ -471,7 +511,11 @@ public class Manager {
public
var
dataTaskDidReceiveData
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSData
)
->
Void
)?
public
var
dataTaskDidReceiveData
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSData
)
->
Void
)?
/// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:willCacheResponse:completionHandler:`.
/// Overrides default behavior for NSURLSessionDataDelegate method `URLSession:dataTask:willCacheResponse:completionHandler:`.
public
var
dataTaskWillCacheResponse
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSCachedURLResponse
)
->
NSCachedURLResponse
!
)?
public
var
dataTaskWillCacheResponse
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSCachedURLResponse
)
->
NSCachedURLResponse
?)?
/// Overrides all behavior for NSURLSessionDataDelegate method `URLSession:dataTask:willCacheResponse:completionHandler:` and
/// requires caller to call the `completionHandler`.
public
var
dataTaskWillCacheResponseWithCompletion
:
((
NSURLSession
,
NSURLSessionDataTask
,
NSCachedURLResponse
,
NSCachedURLResponse
?
->
Void
)
->
Void
)?
// MARK: Delegate Methods
// MARK: Delegate Methods
...
@@ -489,8 +533,13 @@ public class Manager {
...
@@ -489,8 +533,13 @@ public class Manager {
session
:
NSURLSession
,
session
:
NSURLSession
,
dataTask
:
NSURLSessionDataTask
,
dataTask
:
NSURLSessionDataTask
,
didReceiveResponse
response
:
NSURLResponse
,
didReceiveResponse
response
:
NSURLResponse
,
completionHandler
:
((
NSURLSessionResponseDisposition
)
->
Void
)
)
completionHandler
:
NSURLSessionResponseDisposition
->
Void
)
{
{
guard
dataTaskDidReceiveResponseWithCompletion
==
nil
else
{
dataTaskDidReceiveResponseWithCompletion
?(
session
,
dataTask
,
response
,
completionHandler
)
return
}
var
disposition
:
NSURLSessionResponseDisposition
=
.
Allow
var
disposition
:
NSURLSessionResponseDisposition
=
.
Allow
if
let
dataTaskDidReceiveResponse
=
dataTaskDidReceiveResponse
{
if
let
dataTaskDidReceiveResponse
=
dataTaskDidReceiveResponse
{
...
@@ -552,8 +601,13 @@ public class Manager {
...
@@ -552,8 +601,13 @@ public class Manager {
session
:
NSURLSession
,
session
:
NSURLSession
,
dataTask
:
NSURLSessionDataTask
,
dataTask
:
NSURLSessionDataTask
,
willCacheResponse
proposedResponse
:
NSCachedURLResponse
,
willCacheResponse
proposedResponse
:
NSCachedURLResponse
,
completionHandler
:
((
NSCachedURLResponse
?)
->
Void
)
)
completionHandler
:
NSCachedURLResponse
?
->
Void
)
{
{
guard
dataTaskWillCacheResponseWithCompletion
==
nil
else
{
dataTaskWillCacheResponseWithCompletion
?(
session
,
dataTask
,
proposedResponse
,
completionHandler
)
return
}
if
let
dataTaskWillCacheResponse
=
dataTaskWillCacheResponse
{
if
let
dataTaskWillCacheResponse
=
dataTaskWillCacheResponse
{
completionHandler
(
dataTaskWillCacheResponse
(
session
,
dataTask
,
proposedResponse
))
completionHandler
(
dataTaskWillCacheResponse
(
session
,
dataTask
,
proposedResponse
))
}
else
if
let
delegate
=
self
[
dataTask
]
as?
Request
.
DataTaskDelegate
{
}
else
if
let
delegate
=
self
[
dataTask
]
as?
Request
.
DataTaskDelegate
{
...
@@ -676,16 +730,20 @@ public class Manager {
...
@@ -676,16 +730,20 @@ public class Manager {
// MARK: - NSObject
// MARK: - NSObject
public
override
func
respondsToSelector
(
selector
:
Selector
)
->
Bool
{
public
override
func
respondsToSelector
(
selector
:
Selector
)
->
Bool
{
#if !os(OSX)
if
selector
==
#selector(
NSURLSessionDelegate.URLSessionDidFinishEventsForBackgroundURLSession(_:)
)
{
return
sessionDidFinishEventsForBackgroundURLSession
!=
nil
}
#endif
switch
selector
{
switch
selector
{
case
"URLSession:didBecomeInvalidWithError:"
:
case
#selector(
NSURLSessionDelegate.URLSession(_:didBecomeInvalidWithError:)
)
:
return
sessionDidBecomeInvalidWithError
!=
nil
return
sessionDidBecomeInvalidWithError
!=
nil
case
"URLSession:didReceiveChallenge:completionHandler:"
:
case
#selector(
NSURLSessionDelegate.URLSession(_:didReceiveChallenge:completionHandler:)
)
:
return
sessionDidReceiveChallenge
!=
nil
return
sessionDidReceiveChallenge
!=
nil
case
"URLSessionDidFinishEventsForBackgroundURLSession:"
:
case
#selector(
NSURLSessionTaskDelegate.URLSession(_:task:willPerformHTTPRedirection:newRequest:completionHandler:)
)
:
return
sessionDidFinishEventsForBackgroundURLSession
!=
nil
case
"URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:"
:
return
taskWillPerformHTTPRedirection
!=
nil
return
taskWillPerformHTTPRedirection
!=
nil
case
"URLSession:dataTask:didReceiveResponse:completionHandler:"
:
case
#selector(
NSURLSessionDataDelegate.URLSession(_:dataTask:didReceiveResponse:completionHandler:)
)
:
return
dataTaskDidReceiveResponse
!=
nil
return
dataTaskDidReceiveResponse
!=
nil
default
:
default
:
return
self
.
dynamicType
.
instancesRespondToSelector
(
selector
)
return
self
.
dynamicType
.
instancesRespondToSelector
(
selector
)
...
...
examples/Alamofire Example/Alamofire/Source/MultipartFormData.swift
View file @
3d534c3b
...
@@ -428,7 +428,6 @@ public class MultipartFormData {
...
@@ -428,7 +428,6 @@ public class MultipartFormData {
throw
Error
.
errorWithCode
(
NSURLErrorCannotOpenFile
,
failureReason
:
failureReason
)
throw
Error
.
errorWithCode
(
NSURLErrorCannotOpenFile
,
failureReason
:
failureReason
)
}
}
outputStream
.
scheduleInRunLoop
(
NSRunLoop
.
currentRunLoop
(),
forMode
:
NSDefaultRunLoopMode
)
outputStream
.
open
()
outputStream
.
open
()
self
.
bodyParts
.
first
?
.
hasInitialBoundary
=
true
self
.
bodyParts
.
first
?
.
hasInitialBoundary
=
true
...
@@ -439,7 +438,6 @@ public class MultipartFormData {
...
@@ -439,7 +438,6 @@ public class MultipartFormData {
}
}
outputStream
.
close
()
outputStream
.
close
()
outputStream
.
removeFromRunLoop
(
NSRunLoop
.
currentRunLoop
(),
forMode
:
NSDefaultRunLoopMode
)
}
}
// MARK: - Private - Body Part Encoding
// MARK: - Private - Body Part Encoding
...
@@ -476,7 +474,6 @@ public class MultipartFormData {
...
@@ -476,7 +474,6 @@ public class MultipartFormData {
private
func
encodeBodyStreamDataForBodyPart
(
bodyPart
:
BodyPart
)
throws
->
NSData
{
private
func
encodeBodyStreamDataForBodyPart
(
bodyPart
:
BodyPart
)
throws
->
NSData
{
let
inputStream
=
bodyPart
.
bodyStream
let
inputStream
=
bodyPart
.
bodyStream
inputStream
.
scheduleInRunLoop
(
NSRunLoop
.
currentRunLoop
(),
forMode
:
NSDefaultRunLoopMode
)
inputStream
.
open
()
inputStream
.
open
()
var
error
:
NSError
?
var
error
:
NSError
?
...
@@ -503,7 +500,6 @@ public class MultipartFormData {
...
@@ -503,7 +500,6 @@ public class MultipartFormData {
}
}
inputStream
.
close
()
inputStream
.
close
()
inputStream
.
removeFromRunLoop
(
NSRunLoop
.
currentRunLoop
(),
forMode
:
NSDefaultRunLoopMode
)
if
let
error
=
error
{
if
let
error
=
error
{
throw
error
throw
error
...
@@ -537,7 +533,6 @@ public class MultipartFormData {
...
@@ -537,7 +533,6 @@ public class MultipartFormData {
private
func
writeBodyStreamForBodyPart
(
bodyPart
:
BodyPart
,
toOutputStream
outputStream
:
NSOutputStream
)
throws
{
private
func
writeBodyStreamForBodyPart
(
bodyPart
:
BodyPart
,
toOutputStream
outputStream
:
NSOutputStream
)
throws
{
let
inputStream
=
bodyPart
.
bodyStream
let
inputStream
=
bodyPart
.
bodyStream
inputStream
.
scheduleInRunLoop
(
NSRunLoop
.
currentRunLoop
(),
forMode
:
NSDefaultRunLoopMode
)
inputStream
.
open
()
inputStream
.
open
()
while
inputStream
.
hasBytesAvailable
{
while
inputStream
.
hasBytesAvailable
{
...
@@ -563,7 +558,6 @@ public class MultipartFormData {
...
@@ -563,7 +558,6 @@ public class MultipartFormData {
}
}
inputStream
.
close
()
inputStream
.
close
()
inputStream
.
removeFromRunLoop
(
NSRunLoop
.
currentRunLoop
(),
forMode
:
NSDefaultRunLoopMode
)
}
}
private
func
writeFinalBoundaryDataForBodyPart
(
private
func
writeFinalBoundaryDataForBodyPart
(
...
...
examples/Alamofire Example/Alamofire/Source/NetworkReachabilityManager.swift
View file @
3d534c3b
...
@@ -114,11 +114,12 @@ public class NetworkReachabilityManager {
...
@@ -114,11 +114,12 @@ public class NetworkReachabilityManager {
}
}
/**
/**
Creates a `NetworkReachabilityManager` instance with the default socket
address (`sockaddr_in6`)
.
Creates a `NetworkReachabilityManager` instance with the default socket
IPv4 or IPv6 address
.
- returns: The new `NetworkReachabilityManager` instance.
- returns: The new `NetworkReachabilityManager` instance.
*/
*/
public
convenience
init
?()
{
public
convenience
init
?()
{
if
#available(iOS 9.0, OSX 10.10, *)
{
var
address
=
sockaddr_in6
()
var
address
=
sockaddr_in6
()
address
.
sin6_len
=
UInt8
(
sizeofValue
(
address
))
address
.
sin6_len
=
UInt8
(
sizeofValue
(
address
))
address
.
sin6_family
=
sa_family_t
(
AF_INET6
)
address
.
sin6_family
=
sa_family_t
(
AF_INET6
)
...
@@ -128,6 +129,17 @@ public class NetworkReachabilityManager {
...
@@ -128,6 +129,17 @@ public class NetworkReachabilityManager {
})
else
{
return
nil
}
})
else
{
return
nil
}
self
.
init
(
reachability
:
reachability
)
self
.
init
(
reachability
:
reachability
)
}
else
{
var
address
=
sockaddr_in
()
address
.
sin_len
=
UInt8
(
sizeofValue
(
address
))
address
.
sin_family
=
sa_family_t
(
AF_INET
)
guard
let
reachability
=
withUnsafePointer
(
&
address
,
{
SCNetworkReachabilityCreateWithAddress
(
nil
,
UnsafePointer
(
$0
))
})
else
{
return
nil
}
self
.
init
(
reachability
:
reachability
)
}
}
}
private
init
(
reachability
:
SCNetworkReachability
)
{
private
init
(
reachability
:
SCNetworkReachability
)
{
...
...
examples/Alamofire Example/Alamofire/Source/ParameterEncoding.swift
View file @
3d534c3b
...
@@ -244,7 +244,7 @@ public enum ParameterEncoding {
...
@@ -244,7 +244,7 @@ public enum ParameterEncoding {
while
index
!=
string
.
endIndex
{
while
index
!=
string
.
endIndex
{
let
startIndex
=
index
let
startIndex
=
index
let
endIndex
=
index
.
advancedBy
(
batchSize
,
limit
:
string
.
endIndex
)
let
endIndex
=
index
.
advancedBy
(
batchSize
,
limit
:
string
.
endIndex
)
let
range
=
Range
(
start
:
startIndex
,
end
:
endIndex
)
let
range
=
startIndex
..<
endIndex
let
substring
=
string
.
substringWithRange
(
range
)
let
substring
=
string
.
substringWithRange
(
range
)
...
...
examples/Alamofire Example/Alamofire/Source/Request.swift
View file @
3d534c3b
...
@@ -484,7 +484,7 @@ extension Request: CustomDebugStringConvertible {
...
@@ -484,7 +484,7 @@ extension Request: CustomDebugStringConvertible {
let
protectionSpace
=
NSURLProtectionSpace
(
let
protectionSpace
=
NSURLProtectionSpace
(
host
:
host
,
host
:
host
,
port
:
URL
.
port
?
.
integerValue
??
0
,
port
:
URL
.
port
?
.
integerValue
??
0
,
`
protocol
`
:
URL
.
scheme
,
protocol
:
URL
.
scheme
,
realm
:
host
,
realm
:
host
,
authenticationMethod
:
NSURLAuthenticationMethodHTTPBasic
authenticationMethod
:
NSURLAuthenticationMethodHTTPBasic
)
)
...
...
examples/Alamofire Example/Alamofire/Source/ResponseSerialization.swift
View file @
3d534c3b
...
@@ -29,10 +29,10 @@ import Foundation
...
@@ -29,10 +29,10 @@ import Foundation
*/
*/
public
protocol
ResponseSerializerType
{
public
protocol
ResponseSerializerType
{
/// The type of serialized object to be created by this `ResponseSerializerType`.
/// The type of serialized object to be created by this `ResponseSerializerType`.
typealias
SerializedObject
associatedtype
SerializedObject
/// The type of error to be created by this `ResponseSerializer` if serialization fails.
/// The type of error to be created by this `ResponseSerializer` if serialization fails.
typealias
ErrorObject
:
ErrorType
associatedtype
ErrorObject
:
ErrorType
/**
/**
A closure used by response handlers that takes a request, response, data and error and returns a result.
A closure used by response handlers that takes a request, response, data and error and returns a result.
...
@@ -176,8 +176,12 @@ extension Request {
...
@@ -176,8 +176,12 @@ extension Request {
- returns: The request.
- returns: The request.
*/
*/
public
func
responseData
(
completionHandler
:
Response
<
NSData
,
NSError
>
->
Void
)
->
Self
{
public
func
responseData
(
return
response
(
responseSerializer
:
Request
.
dataResponseSerializer
(),
completionHandler
:
completionHandler
)
queue
queue
:
dispatch_queue_t
?
=
nil
,
completionHandler
:
Response
<
NSData
,
NSError
>
->
Void
)
->
Self
{
return
response
(
queue
:
queue
,
responseSerializer
:
Request
.
dataResponseSerializer
(),
completionHandler
:
completionHandler
)
}
}
}
}
...
@@ -240,11 +244,13 @@ extension Request {
...
@@ -240,11 +244,13 @@ extension Request {
- returns: The request.
- returns: The request.
*/
*/
public
func
responseString
(
public
func
responseString
(
encoding
encoding
:
NSStringEncoding
?
=
nil
,
queue
queue
:
dispatch_queue_t
?
=
nil
,
encoding
:
NSStringEncoding
?
=
nil
,
completionHandler
:
Response
<
String
,
NSError
>
->
Void
)
completionHandler
:
Response
<
String
,
NSError
>
->
Void
)
->
Self
->
Self
{
{
return
response
(
return
response
(
queue
:
queue
,
responseSerializer
:
Request
.
stringResponseSerializer
(
encoding
:
encoding
),
responseSerializer
:
Request
.
stringResponseSerializer
(
encoding
:
encoding
),
completionHandler
:
completionHandler
completionHandler
:
completionHandler
)
)
...
@@ -296,11 +302,13 @@ extension Request {
...
@@ -296,11 +302,13 @@ extension Request {
- returns: The request.
- returns: The request.
*/
*/
public
func
responseJSON
(
public
func
responseJSON
(
options
options
:
NSJSONReadingOptions
=
.
AllowFragments
,
queue
queue
:
dispatch_queue_t
?
=
nil
,
options
:
NSJSONReadingOptions
=
.
AllowFragments
,
completionHandler
:
Response
<
AnyObject
,
NSError
>
->
Void
)
completionHandler
:
Response
<
AnyObject
,
NSError
>
->
Void
)
->
Self
->
Self
{
{
return
response
(
return
response
(
queue
:
queue
,
responseSerializer
:
Request
.
JSONResponseSerializer
(
options
:
options
),
responseSerializer
:
Request
.
JSONResponseSerializer
(
options
:
options
),
completionHandler
:
completionHandler
completionHandler
:
completionHandler
)
)
...
@@ -354,11 +362,13 @@ extension Request {
...
@@ -354,11 +362,13 @@ extension Request {
- returns: The request.
- returns: The request.
*/
*/
public
func
responsePropertyList
(
public
func
responsePropertyList
(
options
options
:
NSPropertyListReadOptions
=
NSPropertyListReadOptions
(),
queue
queue
:
dispatch_queue_t
?
=
nil
,
options
:
NSPropertyListReadOptions
=
NSPropertyListReadOptions
(),
completionHandler
:
Response
<
AnyObject
,
NSError
>
->
Void
)
completionHandler
:
Response
<
AnyObject
,
NSError
>
->
Void
)
->
Self
->
Self
{
{
return
response
(
return
response
(
queue
:
queue
,
responseSerializer
:
Request
.
propertyListResponseSerializer
(
options
:
options
),
responseSerializer
:
Request
.
propertyListResponseSerializer
(
options
:
options
),
completionHandler
:
completionHandler
completionHandler
:
completionHandler
)
)
...
...
examples/Alamofire Example/Example/DetailViewController.swift
View file @
3d534c3b
...
@@ -46,7 +46,7 @@ class DetailViewController: UITableViewController {
...
@@ -46,7 +46,7 @@ class DetailViewController: UITableViewController {
override
func
awakeFromNib
()
{
override
func
awakeFromNib
()
{
super
.
awakeFromNib
()
super
.
awakeFromNib
()
self
.
refreshControl
?
.
addTarget
(
self
,
action
:
"refresh"
,
forControlEvents
:
.
ValueChanged
)
self
.
refreshControl
?
.
addTarget
(
self
,
action
:
#selector(
DetailViewController.refresh
)
,
forControlEvents
:
.
ValueChanged
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment