[英]How to use ReactiveCocoa to sendKeypath when the type of return value is CGFloat
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.
我认为如果还有另一种方法可以反应类型为float,int等的值,.i会接受
您应该使用字符串而不是@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;
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.