Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何传递参数
-(void)errorValue:(void(^)(NSError*))error{ [self errMssg]; } -(void)call{ (void(^)(NSError*))error; [self errorValue ?]; }
请让我知道如何将 (void(^)(NSError*))error 传递给该方法!
@All 提前致谢
您需要先正确声明一个块变量。然后你只需像任何其他变量一样按名称传递它:
void(^myBlock)(NSError *) = ^(NSError* error) { // Do something }; [self errorValue:myBlock];
或者,您可以直接传递块文字:
[self errorValue:^(NSError* error) { // Do something }];