Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C block parameter Issue: This block declaration is not a prototype

I am learning ReactiveObjC , the ReactiveCocoa Objective-C version.

For the code following: In RACSignal.h ,

- (RACSignal *)reduceEach:(id _Nullable (^)())reduceBlock RAC_WARN_UNUSED_RESULT;

(id _Nullable (^)())

Xcode reports a error:

This block declaration is not a prototype

Multiple parameters could be put in the reduceBlock(). As the code following: In UIAlertView+RACSignalSupport.m , and others ,

- (RACSignal *)rac_buttonClickedSignal {
    RACSignal *signal = [[[[self.rac_delegateProxy
        signalForSelector:@selector(alertView:clickedButtonAtIndex:)]
        reduceEach:^(UIAlertView *alertView, NSNumber *buttonIndex){
            return buttonIndex;
        }]
    ......
    return signal;
}

Kinda generic. I think I can put zero or more parameters in the block, with void (^block)() declared.

The syntax is not supported now in Xcode. I want to know how to solve it, and why.

Many Thanks in advance.

like image 608
dengApro Avatar asked Dec 21 '17 01:12

dengApro


Video Answer


1 Answers

You can get the "not a prototype" warning when you try to define a function or block prototype using an empty set of parentheses ().

Put a void in the middle of the parens—i.e. (id _Nullable (^)(void)), and you should fix the problem.

like image 108
Charles Srstka Avatar answered Nov 15 '22 20:11

Charles Srstka