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

时间:2013-07-12 13:49:02

标签: ios automatic-ref-counting 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,如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

编译器抱怨,因为UIEventTypeTouches是一个NSInteger(在枚举中定义),而touchesMoved:withEvent:期待一个UIEvent对象。你可以通过传递事件参数nil来逃脱:

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