我在將轉換成3.0
轉換成ReactiveCocoa
時遇到了很多麻煩。在我的sendNext
和sendCompleted
調用中,我總是收到未知的標識符錯誤。Alamofire 3.0 ReactiveCocoa Conversion
public final class Network: Networking {
private let queue = dispatch_queue_create("Beet.BeetModel.Network.Queue", DISPATCH_QUEUE_SERIAL)
public init() { }
public func requestJSON(url: String, parameters: [String : AnyObject]?)
-> SignalProducer<AnyObject, NetworkError>
{
return SignalProducer { observer, disposable in
let serializer = Alamofire.Request.JSONResponseSerializer()
Alamofire.request(.GET, url, parameters: parameters)
.response(queue: self.queue, responseSerializer: serializer) {
_, _, result in
switch result {
case .Success(let value):
sendNext(observer, value)
sendCompleted(observer)
case .Failure(_, let error):
sendError(observer, NetworkError(error: error))
}
}
}
}
}