gpt4 book ai didi

ios - 未连接设备时 Xcode 在 bool 上编译错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:59:01 25 4
gpt4 key购买 nike

我正在尝试使用以下代码片段制作一个简单的动画:

[UIView animateWithDuration:2.0
delay:0.0
options: UIViewAnimationOptionCurveEaseInOut
animations:^{
[self.view setAlpha:0.7f];

}
completion:^(BOOL finished){
if(finished) NSLog(@"Finished !!!!!");
// do any stuff here if you want
}];

但是 XCode 给我一个错误说明:

"Incompatibile block pointer types sending 'void(^)(uint_8t)' to parameter of type 'void(^)(BOOL)'".

如果我尝试将“BOOL”更改为“bool”,那么代码在 iPad Air 上编译时可以正常工作,但是当我断开 iPad 并尝试模拟器时,我会遇到同样的错误,但类型不同:

"Incompatibile block pointer types sending 'void(^)(bool)' to parameter of type 'void(^)(BOOL)'".

在我看来这很奇怪,因为它是一个似乎适用于许多人的代码片段,而且是一段相当标准的代码。是什么导致了这种行为?

附言我还在 - (void)viewWillDisappear:(bool)animated 方法中收到不兼容类型的警告。它们也会在我连接 iPad 时消失,并在断开连接时再次出现。

编辑:----此代码甚至会导致错误:

[searchArray enumerateObjectsUsingBlock:^(NSString *key, NSUInteger idx, BOOL *stop)
{
address = addresses[key];
if(address) *stop = YES;
} ];

也在 BOOL 字段上。错误是相同的,参数类型冲突。

最佳答案

BOOL 是一种不同的类型,具体取决于您是为 32 位编译还是为 64 位编译。使用了不同的类型,如 Bool、bool、Boolean 以及其他可能的类型——确保你在所有地方都使用相同的类型。

插入您的设备意味着将为您的设备而不是模拟器编译代码,因此这可能会在 32 位和 64 位之间变化并触发问题。

我还会检查代码中某处是否有 BOOL 的 typedef 或 #define。双击代码中的 BOOL,右键单击并选择“显示定义”。

关于ios - 未连接设备时 Xcode 在 bool 上编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31337209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com