@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (nonatomic) UIImage *image;
@property (nonatomic) PhotoEffect *effect;
@property (weak, nonatomic) IBOutlet UISwitch *glossSwitch;
I'm trying to update imageView
with a modified image, when UISwitch
changed its value, or _image
and _effect
were changed.
RAC(self.imageView, image) = [RACSignal
combineLatest:@[ RACObserve(self, image), RACObserve(self.glossSwitch, on), RACObserve(self, effect)]
reduce:^(UIImage *im, NSNumber *gloss, PhotoEffect *effect) {
if (!im) {
return nil;
}
if (effect) {
im = [im imageWithEffect:effect.type];
}
if (gloss.boolValue) {
im = [GlossyIcon applyShineToImage:im];
}
return im;
}];
This code gives a compiler error, which I can't understand:
Return type 'UIImage *' must match previous return type 'void *'
when block literal has unspecified explicit return type
Since your reduce block can return nil
or UIImage *
, the compiler can't infer the return type of the block. Explicitly declaring a return type for the reduce block will fix the problem, you can use id
for brevity, or UIImage *
to be clear.
reduce:^UIImage * (UIImage *im, …) {