gpt4 book ai didi

ios - Xcode 7 - 不兼容的 block 指针类型

转载 作者:可可西里 更新时间:2023-11-01 05:33:27 26 4
gpt4 key购买 nike

此代码在 Xcode 6 中运行良好,但现在无法在 Xcode 7 中编译。关于如何解决以及为什么这是 Xcode 7 中的问题有什么想法吗?

Incompatible block pointer types sending 'void (^)(SKSpriteNode *__strong, NSUInteger, BOOL *)' to parameter of type 'void (^ _Nonnull)(SKNode * _Nonnull __strong, NSUInteger, BOOL * _Nonnull)'

[self.children enumerateObjectsUsingBlock:^(SKSpriteNode * node, NSUInteger idx,BOOL *stop)
{
float parallaxRatio = [(NSNumber *)node.userData[@"ParallaxRatio"] floatValue];
CGPoint childVelocity = CGPointMultiplyScalar(self.velocity, parallaxRatio);
CGPoint offset = CGPointMultiplyScalar(childVelocity, deltaTime);
node.position = CGPointAdd(node.position, offset);
}];

最佳答案

几个界面似乎随着 iOS9/Xcode7 发生了变化。在这种情况下,您最容易修复它,方法是键入 [self.children enum,然后按 Ctrl+Space 并从列表。这将为您提供具有新 block 指针类型的代码片段,您可以将代码移入其中。

结果是这样的:(node 自动完成后是obj,我只是重命名了它)

[self.children enumerateObjectsUsingBlock:^(SKNode * _Nonnull node, NSUInteger idx, BOOL * _Nonnull stop) 
{
float parallaxRatio = [(NSNumber *)node.userData[@"ParallaxRatio"] floatValue];
CGPoint childVelocity = CGPointMultiplyScalar(self.velocity, parallaxRatio);
CGPoint offset = CGPointMultiplyScalar(childVelocity, deltaTime);
node.position = CGPointAdd(node.position, offset);
}];

关于ios - Xcode 7 - 不兼容的 block 指针类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32724880/

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