RAC 知识点(三)

来源:互联网 发布:高考复读知乎 编辑:程序博客网 时间:2024/06/16 00:13

#import "NSObject+RACSelectorSignal.h"

导入这个头文件所有继承于NSObject的类都可以调取这个方法


/// Creates a signal associated with the receiver, which will send a tuple of the

/// method's arguments each time the given selector is invoked.

这个信号将会发送这个方法参数

a tuple of the method's arguments  方法的参数

each time the given selector is invoked  每次方法被调用的时候

///

/// If the selector is already implemented on the receiver, the existing

/// implementation will be invoked _before_ the signal fires.

如果这个方法在接受者的类里已经实现了,那么存在的实现会在信号触发之前调用

///

/// If the selector is not yet implemented on the receiver, the injected

/// implementation will have a `void` return type and accept only object

/// arguments. Invoking the added implementation with non-object values, or

/// expecting a return value, will result in undefined behavior.

如果这个方法在接受者的类里没有实现,注入的实现会有一个  void的返回类型  和只能接受对象参数;

用非对象的值调用已添加的实现或者期望获得一个返回值将会导致没有定义的行为

///

/// This is useful for changing an event or delegate callback into a signal. 

/// For example, on an NSView:

///

///     [[view rac_signalForSelector:@selector(mouseDown:)] subscribeNext:^(RACTuple *args) {

///         NSEvent *event = args.first;

///         NSLog(@"mouse button pressed: %@", event);

///     }];

///

/// selector - The selector for whose invocations are to be observed. 

这个方法的调用要被观察

If it doesn't exist, it will be implemented to accept object arguments and return void.

This cannot have C arrays or unions as arguments or C arrays, unions, structs, complex or vector types as return type.

///

/// Returns a signal which will send a tuple of arguments upon each invocation of the selector, 

// then completes when the receiver is deallocated. 

// `next` events will be sent synchronously from the thread that invoked the method. 

// If a runtime call fails, the signal will send an error in the RACSelectorSignalErrorDomain.

- (RACSignal *)rac_signalForSelector:(SEL)selector;




0 0
原创粉丝点击