iOS:Used 类型 'CGRect'(又名 'struct CGRect'),其中需要算术或指针类型

iOS:Used type 'CGRect' (aka 'struct CGRect') where arithmetic or pointer type is required

当我使用ReactiveCocoa时,我想观察我的tableView的框架,但是出现了一个问题:

__block CGRect tmp_rect;
[RACObserve(self, self.tableView.frame) subscribeNext:^(id x) {
    NSLog(@"%@",x);

    tmp_rect= (CGRect)x; // this line appear issue:
     'Used type 'CGRect' (aka 'struct CGRect') where arithmetic or pointer type is required'

    double width_radio = x.origin.x/[UIScreen mainScreen].bounds.size.width;

    back_nav.alpha = 1 - width_radio;
}];

我不知道这个问题出现了什么。

对象 x 是一个 NSValue。

您需要从中解包 CGRect。你不能只施放它。

尝试...

tmp_rect = [x CGRectValue];