Xcode 7 - 不兼容的块指针类型

Mik*_*keJ 4 objective-c ios xcode7

这段代码在Xcode 6中运行良好,但现在无法在Xcode 7中编译.任何想法如何修复以及为什么这是Xcode 7中的一个问题?

不兼容的块指针类型将'void(^)(SKSpriteNode*__ strong,NSUInteger,BOOL*)'发送到'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);
}];
Run Code Online (Sandbox Code Playgroud)

Rai*_*rze 5

iOS9/Xcode7似乎改变了几个界面.在这种情况下,您最容易修复它,通过键入[self.children enum,然后按Ctrl+Space并从列表中选择适当的方法.这将为您提供具有新块指针类型的代码片段,您可以在其中移动代码.

结果将是:( nodeobj自动完成以后,我只是给它改名)

[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);
}];
Run Code Online (Sandbox Code Playgroud)