ARC 不允许将"NSInteger"(又名"int")隐式转换为"UIEvent *"



这是我的相关代码:

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];

最新更新