coolly coolly - 1 year ago 104
iOS Question

How to get error value from a subscribed RACSignal?

For example:

In one controller, implementation

func sendSuccessOrNot()->RACSignal {
// code here

In another controller, calling that signal

controller.sendSuccessOrNot().subscribeNext {


how to check in the above calling if sendSuccessOrNot is sending error or success value in ReactiveCocoa.

Answer Source

The syntax you use makes me think you're using Swift, in which case you shouldn't be using RACSignal, you should be converting your RACSignal to a SignalProducer with .toSignalProducer()

controller.sendSuccessOrNot().toSignalProducer().on(next: { value in
    print("next: \(value)")
failed: { error in
    print("failed: \(error)")

If you're still using RAC 2 then it'd be

controller.sendSuccessOrNot().subscribeNext({ value in
    print("next: \(value)")
}, error: { error in
    print("failed: \(error)")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download