简体   繁体   English

如何将NSError传递给方法

[英]How to pass NSError to method

I have a method which take the parameter 我有一个采用参数的方法

(void(^)(NSError*))errorCall;

I need to pass errorCall value 我需要传递errorCall值

-(void)message{

example = [[Example alloc]init]
[example opertationError:void(^)(NSError*))errorCall ]; 
}

for the below line 对于下面的行

[example opertationError:void(^)(NSError*))errorCall];

i need to pass some custom error call which in type of void(^)(NSError*))errorCall 我需要传递一些自定义错误调用,其类型为void(^)(NSError*))errorCall

Please any one let me know how to pass this kind of error value to the method. 请让我知道如何将这种错误值传递给该方法。

@All @所有

Thanks in advance 提前致谢

You can do like this: 您可以这样:

void(^aBlock)(NSError *) = ^(NSError *error) {
    ...
};
[self errorValue:aBlock];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM