0
       self.subscription = [[[RACObserve(photoModel, fullsizedData) filter:^BOOL(id value) {
                return value != nil;
          }]map:^id(id value) {
    return [NSNumber numberWithFloat:1.0f];
    } ]setKeyPath:@keypath(self.imageView.layer,borderWidth)onObject:self.imageView];

错误日志是:

   Terminating app due to uncaught exception 'NSUnknownKeyException',
   reason: '[<UIImageView 0x7b1a8510> setValue:forUndefinedKey:]:
   this class is not key value coding-compliant for the key cornerRadius.

我认为如果有另一种方法来反应类型是浮点数、整数等的值。我会接受它

4

1 回答 1

3

您应该使用字符串而不是@keypath宏。

    [... setKeyPath:"layer.borderWidth" onObject:self.imageView];

或者您可以使用更清晰的 RAC 宏。

    RAC(self.imageView, layer.borderWidth)
    = [[RACObserve(photoModel, fullsizedData) filter:^BOOL(id value) {
        return value != nil;
    }] map:^id(id value) {
        return @1.0f;
    }];
于 2015-10-09T14:01:10.160 回答