ReactiveCocoa--RACTuple

406 查看

基本信息

父类 NSObject
子类
类含义 RAC元素类
遵循的协议 <NSCopying> <NSCoding> <NSFastEnumeration>
属性 NSUInteger count 包含元素的个数
id first; 元素数组第一个
id second; 元素数组第二个
id third 元素数组第三个
id fourth 元素数组第四个
id fifth 元素数组第五个
id last 元素数组最后一个

例子

    [[self rac_signalForSelector:@selector(tableView:didSelectRowAtIndexPath:)
                    fromProtocol:@protocol(UITableViewDelegate)] subscribeNext:^(RACTuple *tuple) {
        NSLog(@"%@", tuple.first);
        NSLog(@"%@", tuple.second);
    }];

和协议配合使用的比较多


方法介绍

    + (instancetype)tupleWithObjectsFromArray:(NSArray *)array;

初始化一个RACTuple对象数据来自一个数组


    + (instancetype)tupleWithObjectsFromArray:(NSArray *)array convertNullsToNils:(BOOL)convert;

初始化一个RACTuple对象数据来自一个数组,如果convert设置为YES,那么NSNull值会被转换为RACTupleNil


    + (instancetype)tupleWithObjects:(id)object, ... NS_REQUIRES_NIL_TERMINATION;

初始化一个RACTuple对象数据来自一个数组


- (NSArray *)allObjects;

返回元素数组


- (instancetype)tupleByAddingObject:(id)obj;

还可以增加元素


其他

配合Delegate使用的一个例子以及github地址