如何修复不兼容的块指针类型发送错误
How to fix the Incompatible block pointer types sending error
构建失败,因为不兼容的块指针类型发送错误。
- (void)loadAndConfigureWithCompletion:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completion;
[SkyIdConfigure.shared loadAndConfigureWithCompletion:^(BOOL *isConfigured,NSError *error){
if (error) {
}
if (isConfigured) {
}
}];
我有这个错误!!
Incompatible block pointer types sending 'int (^)(BOOL *, NSError * _Nullable)' to parameter of type 'void (^ _Nonnull)(BOOL, NSError * _Nullable)' Incompatible block pointer types sending 'void (^)(BOOL *, NSError *)' to parameter of type 'void (^ _Nonnull)(BOOL, NSError * _Nullable)'
我们来看一条错误信息!
小提示,将预期和当前放在另一个之上,会更容易发现差异。当我无法发现差异时,我会这样做。
Incompatible block pointer types sending 'void (^)(BOOL *, NSError *)' to parameter of type 'void (^ _Nonnull)(BOOL, NSError * _Nullable)'
=>
Incompatible block pointer types sending
'void (^)(BOOL *, NSError *)'
to parameter of type
'void (^ _Nonnull)(BOOL, NSError * _Nullable)'
=>
'void (^)(BOOL *, NSError *)' //You wrote
'void (^ _Nonnull)(BOOL, NSError * _Nullable)' //Expected
=>
'void (^ )(BOOL *, NSError * )' //You wrote
'void (^ _Nonnull)(BOOL , NSError * _Nullable)' //Expected
^
|____________________________
|
Nonnull
/Nullable
,这是一回事,但您注意到布尔值的额外 *
了吗?
你有一个指针,你直接有值。
[SkyIdConfigure.shared loadAndConfigureWithCompletion:^(BOOL *isConfigured, NSError *error) {
}];
=>
[SkyIdConfigure.shared loadAndConfigureWithCompletion:^(BOOL isConfigured, NSError *error) {
}];
构建失败,因为不兼容的块指针类型发送错误。
- (void)loadAndConfigureWithCompletion:(void (^ _Nonnull)(BOOL, NSError * _Nullable))completion;
[SkyIdConfigure.shared loadAndConfigureWithCompletion:^(BOOL *isConfigured,NSError *error){
if (error) {
}
if (isConfigured) {
}
}];
我有这个错误!!
Incompatible block pointer types sending 'int (^)(BOOL *, NSError * _Nullable)' to parameter of type 'void (^ _Nonnull)(BOOL, NSError * _Nullable)' Incompatible block pointer types sending 'void (^)(BOOL *, NSError *)' to parameter of type 'void (^ _Nonnull)(BOOL, NSError * _Nullable)'
我们来看一条错误信息!
小提示,将预期和当前放在另一个之上,会更容易发现差异。当我无法发现差异时,我会这样做。
Incompatible block pointer types sending 'void (^)(BOOL *, NSError *)' to parameter of type 'void (^ _Nonnull)(BOOL, NSError * _Nullable)'
=>
Incompatible block pointer types sending
'void (^)(BOOL *, NSError *)'
to parameter of type
'void (^ _Nonnull)(BOOL, NSError * _Nullable)'
=>
'void (^)(BOOL *, NSError *)' //You wrote
'void (^ _Nonnull)(BOOL, NSError * _Nullable)' //Expected
=>
'void (^ )(BOOL *, NSError * )' //You wrote
'void (^ _Nonnull)(BOOL , NSError * _Nullable)' //Expected
^
|____________________________
|
Nonnull
/Nullable
,这是一回事,但您注意到布尔值的额外 *
了吗?
你有一个指针,你直接有值。
[SkyIdConfigure.shared loadAndConfigureWithCompletion:^(BOOL *isConfigured, NSError *error) {
}];
=>
[SkyIdConfigure.shared loadAndConfigureWithCompletion:^(BOOL isConfigured, NSError *error) {
}];