繁体   English   中英

ARC不允许将'NSInteger'(aka'int')隐式转换为'UIEvent *'

[英]implicit conversion of 'NSInteger' (aka 'int') to 'UIEvent *' is disallowed with ARC

这是我的相关代码:

UITouch *touch;         
NSArray *touches = [NSArray arrayWithObject:touch];
//The statement below throw the LLVM compiler error
[self touchesMoved:[NSSet setWithArray:touches] withEvent:UIEventTypeTouches];

这是touchesMoved:withEvent:方法的声明:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

好像我需要将UIEventTypeTouches明确转换为UIEvent ,如何解决呢?

编译器抱怨是因为UIEventTypeTouches是NSInteger(在枚举中定义),并且touchesMoved:withEvent:需要UIEvent对象。 您可能只需为事件参数传递nil就可以逃脱:

[self touchesMoved:[NSSet setWithArray:touches] withEvent:nil];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM