Xcode 7 – 不兼容的块指针types

这段代码在Xcode 6中工作正常,但现在不能在Xcode 7中编译。任何想法如何解决,为什么这是Xcode 7中的问题?

不兼容的指针types将'void(^)(SKSpriteNode * __ strong,NSUInteger,BOOL *)'发送给types为'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中有几个界面已经改变了。 在这种情况下,你最容易修复它,通过input[self.children enum ,然后按Ctrl + 空间,并从列表中select适当的方法。 这会给你一个新的块指针types的代码片段,你可以在那里移动代码。

结果会是这样的:(自动完成后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); }];