Search code examples
iosobjective-creactive-cocoa

ReactiveCocoa: subscribe on property getter access


Can I subscribe to be notified when a property getter is called, using ReactiveCocoa?

I need to set a flag that certain data needs to be updated (via network request) in the near future, because someone accessed it.


Solution

  • I don't know why you'd want to do this, I'd really suggest posting a question that asks what the best way to solve the problem you're seeking to solve. But, yes it's theoretically possible to do what you're asking, using -rac_signalForSelector:.

    [[object rac_signalForSelector:@selector(property)] subscribeNext:^(id value) {
        // Getter has been called
    }];