Objective c 中方法调用的警告
我认为这个问题的答案很简单,我只是不知道如何摆脱这些警告。
当我执行此方法调用时,我收到 'DebugZoneLayer' 可能无法响应 '-getGID:tileKind' 和 初始化从指针生成整数而无需转换:
int blocksCollidableGID = [debugZoneLayer getGID:[NSValue valueWithCGPoint:(NSString*)tileCoord] tileKind:@"blocksCollidable"];
我尝试过铸造这些类型的值的所有不同组合。
在 DebugZoneLayer.h 中我有:
-(int) getGID:(CGPoint)tileCoord withTileKind:(NSString*)tileKind;
谢谢
I think this will be pretty simply answered, I'm just stumped on how to get rid of these warnings.
I'm getting 'DebugZoneLayer' may not respond to '-getGID:tileKind' and Initialization makes integer from pointer without a cast when I do this method call:
int blocksCollidableGID = [debugZoneLayer getGID:[NSValue valueWithCGPoint:(NSString*)tileCoord] tileKind:@"blocksCollidable"];
Which I tried all different combinations of casting those types of values.
In DebugZoneLayer.h I have:
-(int) getGID:(CGPoint)tileCoord withTileKind:(NSString*)tileKind;
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
另外,第一个参数不应该是 NSValue,它应该是 CGPoint。
Also the first parameter should not be an NSValue, it should be a CGPoint.
septi 关于选择器拼写错误的说法是正确的,但似乎还存在一些其他问题。
-valueWithCGPoint:
需要一个CGPoint
。转换为(NSString *)
不正确。什么是tileCoord
?CGPoint
,而不是NSValue
,因此装箱一开始似乎就没有必要。septi is correct about the selector typo, but there seems to be some additional problems as well.
-valueWithCGPoint:
takes, well, aCGPoint
. The cast to(NSString *)
is incorrect. What istileCoord
?CGPoint
, not anNSValue
, so the boxing doesn't seem necessary in the first place.显然应该是withTileKind而不是tileKind。
编辑:我的意思是这一行;-)
编辑:
所以现在你摆脱了警告。现在编译器发现了一些其他错误,就像已经提到的其他错误一样。既然你现在似乎陷入困境,我会尝试猜测该怎么做。
你提到,tileCoord 是一个CGPoint。所以无论如何,绝对没有必要对其进行转换或转换。尝试这行代码:
看看是否还有其他错误。
Obviously it should be withTileKind instead of tileKind.
Edit: I mean this line ;-)
Edit:
so now you got rid of the warning. Now the compiler finds some other errors, like others already mentioned. Since you seem stuck at this point, I'll try to guess what to do.
You mentioned, that tileCoord is a CGPoint. So there is absolutely no need to cast or convert it anyway. Try this line of code:
and see if there are other errors.
不需要进行转换。
tileCoord 或tileKind intblocksCollidableGID = [debugZoneLayer getGID:tileCoord withTileKind:@"blocksCollidable"];
There is no casting that's needed for either tileCoord or tileKind
int blocksCollidableGID = [debugZoneLayer getGID:tileCoord withTileKind:@"blocksCollidable"];