Request
class Request
Extension to Alamofire.Request
for adding a response serialized as a SwiftyJSON
object.
-
Creates a response serializer that returns an object constructed from the response data using
JSON(data:options:error:)
with the specified reading options. Errors are passed as a.Failed
event.Declaration
Swift
public static func swiftyJSONResponseSerializer( options options: NSJSONReadingOptions = .AllowFragments) -> ResponseSerializer<JSON, NSError>
Parameters
options
The json reading options.
.AllowFragments
by default.Return Value
A
JSON
object response serializer. -
Adds a handler to be called once the request has finished.
Declaration
Swift
public func responseSwiftyJSON( options options: NSJSONReadingOptions = .AllowFragments, completionHandler: Response<JSON, NSError> -> Void) -> Self
Parameters
options
The json reading options.
.AllowFragments
by default.completionHandler
A closure to be executed once the request has finished. The closure takes a single argument, the Alamofire
Response<JSON, NSError>
.Return Value
The request.
-
Convenience ReactiveCocoa response using a
swiftyJSONResponseSerializer()
.Seealso
rac_response(_:responseSerializer:)
Declaration
Swift
public func rac_responseSwiftyJSON(queue: dispatch_queue_t? = nil) -> SignalProducer<JSON, NSError>
-
Convenience ReactiveCocoa response using a
swiftyJSONResponseSerializer()
that transforms theJSON
to aJSONCreated
object.Seealso
Declaration
Swift
public func rac_responseSwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, T), NSError>
Return Value
A
SignalProducer
with either theJSONCreated
object as its value or the thrown error frominit(json:)
. -
Convenience ReactiveCocoa response using a
swiftyJSONResponseSerializer()
that transforms theJSON
to an array ofJSONCreated
objects.Seealso
Declaration
Swift
public func rac_responseArraySwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, [T]), NSError>
Return Value
A
SignalProducer
with an array of all theJSONCreated
objects that didn’t throw errors. The original JSON is returned alongside the transformed objects for transparency. This allows the caller to check the JSON count against the transformed count. If theJSON
returned from theswiftyJSONResponseSerializer()
is not anArray
theSignalProducer
has an error created fromunexpectedTypeErrorForJSON(_:expectedType:)
. -
Convenience ReactiveCocoa response using a
swiftyJSONResponseSerializer()
that transforms theJSON
to a dictionary ofJSONCreated
objects.Seealso
Declaration
Swift
public func rac_responseDictionarySwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, [String:T]), NSError>
Return Value
A
SignalProducer
with a dictionary of all theJSONCreated
objects that didn’t throw errors. The original JSON is returned alongside the transformed objects for transparency. This allows the caller to check the JSON count against the transformed count. If theJSON
returned from theswiftyJSONResponseSerializer()
is not aDictionary
theSignalProducer
has an error created fromunexpectedTypeErrorForJSON(_:expectedType:)
.