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.Failedevent.Declaration
Swift
public static func swiftyJSONResponseSerializer( options options: NSJSONReadingOptions = .AllowFragments) -> ResponseSerializer<JSON, NSError>Parameters
optionsThe json reading options.
.AllowFragmentsby default.Return Value
A
JSONobject 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) -> SelfParameters
optionsThe json reading options.
.AllowFragmentsby default.completionHandlerA 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 theJSONto aJSONCreatedobject.Seealso
Declaration
Swift
public func rac_responseSwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, T), NSError>Return Value
A
SignalProducerwith either theJSONCreatedobject as its value or the thrown error frominit(json:). -
Convenience ReactiveCocoa response using a
swiftyJSONResponseSerializer()that transforms theJSONto an array ofJSONCreatedobjects.Seealso
Declaration
Swift
public func rac_responseArraySwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, [T]), NSError>Return Value
A
SignalProducerwith an array of all theJSONCreatedobjects 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 theJSONreturned from theswiftyJSONResponseSerializer()is not anArraytheSignalProducerhas an error created fromunexpectedTypeErrorForJSON(_:expectedType:). -
Convenience ReactiveCocoa response using a
swiftyJSONResponseSerializer()that transforms theJSONto a dictionary ofJSONCreatedobjects.Seealso
Declaration
Swift
public func rac_responseDictionarySwiftyJSONCreated<T:JSONCreated>(queue: dispatch_queue_t? = nil) -> SignalProducer<(JSON, [String:T]), NSError>Return Value
A
SignalProducerwith a dictionary of all theJSONCreatedobjects 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 theJSONreturned from theswiftyJSONResponseSerializer()is not aDictionarytheSignalProducerhas an error created fromunexpectedTypeErrorForJSON(_:expectedType:).
View on GitHub
Request Extension Reference