如何枚举 CGPoints 的 nsmutablearray?
这是我的代码:
for (NSValue * i in cgpointarray){
[text setHidden:NO];
CGPoint temppoint = i.CGPointValue;
if (touchended.x < temppoint.x+36 && touchended.x > temppoint.x-36 && touchended.y < temppoint.y+36 && touchended.y > temppoint.y -36){
spacetouched = i;
break;
}
目的是搜索每个空间(数组的 cgpoint x)+或- 36 像素以查找触摸的 CGPoint。但是,我创建了一个名为 text 的标签并将其设置为隐藏,当此代码运行时,文本标签不会显示,因此我认为它没有执行代码。如果有什么区别的话, cgpointarray 是一个 NSMutableArray 。
编辑:在这一行:CGPoint temppoint = i.CGPointValue;
编译器说:'i'的本地声明隐藏了实例变量
Here is the code I have:
for (NSValue * i in cgpointarray){
[text setHidden:NO];
CGPoint temppoint = i.CGPointValue;
if (touchended.x < temppoint.x+36 && touchended.x > temppoint.x-36 && touchended.y < temppoint.y+36 && touchended.y > temppoint.y -36){
spacetouched = i;
break;
}
The purpose is to search each space (cgpoint x of array) +or- 36 pixels for the touchended CGPoint. However I have created a label named text and set it to hidden, when this code runs the text label does not show up, therefore I think that it is not executing the code. The cgpointarray is an NSMutableArray if that makes any difference.
edit: on this line: CGPoint temppoint = i.CGPointValue;
the compiler says: local declaration of 'i' hides instance variable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么不修复警告 - 似乎您有一个也称为 i 的实例变量?
Why don't you fix the warning - seems like you have an instance variable also called i ?