次のメッセージを使用する際に発生する「Objective-C ポインターから 'const void' への暗黙的な変換は許可されていません」というエラーを修正するにはどうすればよいですか。
NSValue *key = [NSValue valueWithPointer:t];
単純な初心者の用語である場合、このコードがこの例外をスローする理由を提供できる人に感謝します。
それが役立つ場合の完全な方法は次のとおりです。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *t in touches) {
// Is this a double tap?
if ([t tapCount] > 1) {
[self clearAll];
return;
}
// Use the touch object (packed in an NSValue) as the key
NSValue *key = [NSValue valueWithPointer:t]; // here is where the error is
// Create a line for the value
CGPoint loc = [t locationInView:self];
Line *newLine = [[Line alloc] init];
[newLine setBegin:loc];
[newLine setEnd:loc];
// Put pair in dictionary
[linesInProcess setObject:newLine forKey:key];
}