ios - 如何修复不兼容的块指针类型发送错误
问题描述
由于不兼容的块指针类型发送错误,构建失败。
- (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) {
}];
推荐阅读
- python-requests - 使用 python 请求登录失败
- c# - 即使 ID 和 Type 正确,也显示不同的数据
- jquery - 如何将 Id 传递给 Jquery 语句 - ASP.NET MVC
- java - 如何使用Java在数据库中存储日期数组?
- android - recyclerview 列表未在 android 中显示
- java - 如何在 Android Studio 中比较两个带有扩展名和名称的图像?
- visual-studio-code - VsCode:展开时折叠其他侧边栏部分(视图/视图)
- angular - 在Angular 8中的http post请求正文中发送图像文件
- c - C:使用按位运算符替换 int 中特定位置的位
- azure-devops - TFS Git 提交消息验证