Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when using @weakify get error unexpected '@' in the program

When using @weakify, I get error unexpected '@' in the program. Am I missing some .h files? I already imported ReactiveCocoa.h. Is there any thing I should do ?

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        _isSeperateFill = YES;
        _isBorderStroke = NO;
        _isSeperatedStroke = YES;

        _contentWidth = 0;

        @weakify(self);
        [RACObserve(self, dataVO) subscribeNext:^(TableDataVO* dataVO){
            if( dataVO ){
                NSString* indexKey = [[dataVO.tableDataDictionary allKeys] objectAtIndex:0];

                _keys = [dataVO.tableDataDictionary allKeys];
                @strongify(self);
                _rows = [[self.dataVO.tableDataDictionary objectForKey:indexKey] count];
                @strongify(self);
                [self.styleVO setTableHeaderLineHorizontalMargin:self.styleVO.tableWidth / [_keys count]];
            }
        }];

        @weakify(self);
        [RACObserve(self, styleVO) subscribeNext:^(TableStyleVO* styleVO){
            if( styleVO ){
                styleVO.tableHeaderLineHorizontalMargin = styleVO.tableWidth / [_keys count] / 2;
            }
        }];

    }
    return self;
}
like image 1000
benoitcn Avatar asked Aug 14 '14 12:08

benoitcn


1 Answers

@weakify, @strongify and friends are part of libextobjc, not ReactiveCocoa proper.

Try adding this line (per @chakming's comment):

#import "ReactiveCocoa/RACEXTScope.h"

Or for pre-2.3.1 ReactiveCocoa (my original answer), use:

#import <ReactiveCocoa/EXTScope.h>

like image 77
Rob Bajorek Avatar answered Oct 30 '22 00:10

Rob Bajorek