Start with iOS-RAC and start with iOS-RAC

Source: Internet
Author: User

Start with iOS-RAC and start with iOS-RAC
What is RAC?

In fact, RAC is a third-party library ReactiveCocoa that simplifies code. You can directly use Cocoapods to add it to the project. Add the pod 'reactivecocoa 'to the podfile file, and then install the terminal pod. the header file references:

# Import <ReactiveCocoa/ReactiveCocoa. h>
Use RAC

1. Method

The simplest way to use RAC is to listen to events.

For example, if you want to add an event method to a button, we generally do this:

/// Add a click event [self. button addTarget: self action: @ selector (buttonClick :) forControlEvents: UIControlEventTouchUpInside]; // method implementation-(void) buttonClick :( UIButton *) sender {NSLog (@ "click button ");}

However, if RAC is used, you can:

[[Self. button rac_signalForControlEvents: UIControlEventTouchUpInside] subscribeNext: ^ (id x) {NSLog (@ "click button");}];

 

Reference: http://www.jianshu.com/p/ff79a5ae0353

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.