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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
43 additions
and
27 deletions
+43
-27
Alamofire.podspec
examples/Alamofire Example/Alamofire/Alamofire.podspec
+1
-1
Manager.swift
examples/Alamofire Example/Alamofire/Source/Manager.swift
+0
-0
MultipartFormData.swift
...lamofire Example/Alamofire/Source/MultipartFormData.swift
+0
-6
NetworkReachabilityManager.swift
...Example/Alamofire/Source/NetworkReachabilityManager.swift
+22
-10
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
This diff is collapsed.
Click to expand it.
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,20 +114,32 @@ public class NetworkReachabilityManager {
...
@@ -114,20 +114,32 @@ 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
?()
{
var
address
=
sockaddr_in6
()
if
#available(iOS 9.0, OSX 10.10, *)
{
address
.
sin6_len
=
UInt8
(
sizeofValue
(
address
))
var
address
=
sockaddr_in6
()
address
.
sin6_family
=
sa_family_t
(
AF_INET6
)
address
.
sin6_len
=
UInt8
(
sizeofValue
(
address
))
address
.
sin6_family
=
sa_family_t
(
AF_INET6
)
guard
let
reachability
=
withUnsafePointer
(
&
address
,
{
SCNetworkReachabilityCreateWithAddress
(
nil
,
UnsafePointer
(
$0
))
guard
let
reachability
=
withUnsafePointer
(
&
address
,
{
})
else
{
return
nil
}
SCNetworkReachabilityCreateWithAddress
(
nil
,
UnsafePointer
(
$0
))
})
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