Xcode 7 GM

编程入门 行业动态 更新时间:2024-10-10 08:20:33
本文介绍了Xcode 7 GM-无法调用enumerateObjectsUsingBlock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚下载了xcode 7 GM,并尝试使用iOS 9调用NSArray的方法enumerateObjectsUsingBlock,但它在构建时显示了以下错误.

I just downloaded xcode 7 GM and trying to call the method enumerateObjectsUsingBlock of NSArray with iOS 9 but it shows the following error at build time.

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

这是有关enumerateObjectsUsingBlock方法的Apple文档:

This is the Apple documentation about enumerateObjectsUsingBlock method:

- (void)enumerateObjectsUsingBlock:(void (^)(ObjectType obj, NSUInteger idx, BOOL *stop))block

这是我的代码:

[self.children enumerateObjectsUsingBlock:^(SKSpriteNode * child, NSUInteger idx, BOOL *stop) { child.position = CGPointMake(child.position.x-self.scrollingSpeed, child.position.y); if (child.position.x <= -child.size.width){ float delta = child.position.x+child.size.width; child.position = CGPointMake(child.size.width*(self.children.count-1)+delta, child.position.y); } }];

其中self.children是NSArray.

where self.children is a NSArray.

我不明白,我做错了什么?

I don't understand, what am I doing wrong?

推荐答案

您阅读错误消息了吗?您是否在两个地方注意到"nonnull"?在Xcode 7中,有更严格的规则.您有一个保证包含SKNode而不是SKSpriteNode的数组.有些指针必须是非空指针.您需要更改代码以解决此问题.

Did you read the error message? Did you notice the "nonnull" in two places? In Xcode 7, there are stricter rules. You have an array which is guaranteed to contain SKNode, not SKSpriteNode. There are pointers required to be nonnull pointers. You'll need to change your code to handle this.

更多推荐

Xcode 7 GM

本文发布于:2023-11-26 10:36:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Xcode   GM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!