簡體   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