executeRequest(request, session: session) { result in switch result { case let .Failure(error): completion(.Failure(error)) case let .Success(data): let widget = Widget(data: result.value) completion(.Success(widget)) } } }
executeRequest(request, session: session) { httpResult in switch result { case let .Failure(error): completion(.Failure(error)) case let .Success(data): } } }
executeRequest(request, session: session) { httpResult in switch result { case let .Failure(error): completion(.Failure(error)) case let .Success(data): let json = // Parse JSON } } }
executeRequest(request, session: session) { httpResult in switch result { case let .Failure(error): completion(.Failure(error)) case let .Success(data): let json = // Parse JSON let widget = // Instantiate Widget } } }
executeRequest(request, session: session) { httpResult in switch result { case let .Failure(error): completion(.Failure(error)) case let .Success(data): let json = // Parse JSON let widget = // Instantiate Widget completion(.Success(widget)) } } }
executeRequest(request, session: session) { httpResult in switch result { case let .Failure(error): completion(.Failure(error)) case let .Success(data): let json = // Parse JSON // Handle failures let widget = // Instantiate Widget // Handle failures completion(.Success(widget)) } } }
executeRequest(request, session: session) { httpResult in let result = httpResult .flatMap(parseJSONData) .flatMap(parseWidgetJSON) completion(result) } }
let billID: String let completionDate: NSDate } class CompleteBillResponse: PBMessageType { let status: Status let bill: Bill } class Status: PBMessageType { let success: Bool let localizedDescription: String? }
let billID: String let completionDate: NSDate } class CompleteBillResponse: PBMessageType { let status: Status let bill: Bill } class Status: PBMessageType { let success: Bool let localizedDescription: String? }
let billID: String let completionDate: NSDate } class CompleteBillResponse: PBMessageType { let status: Status let bill: Bill } class Status: PBMessageType { let success: Bool let localizedDescription: String? }
data) if object.status.success { // Value of type 'T' has no member 'status' return .Success(value: object) } else { return .Failure(StatusError()) } }