如果用touchesBegan
方法中的情况,我会变得简单:
if ([touch.view isKindOfClass:[Direction class]])
{
//select tapped object and do something...
}
我已查看了许多Direction
个对象,当我点击其中一个时我想选择它,例如:
Direction *d = [touch.view].selectedObject; //something like that.
我可以在obj-C中这样做吗?或者我该如何正确地做到这一点?
答案 0 :(得分:2)
if ([touch.view isKindOfClass:[Direction class]])
{
//do something...
Direction *d = (Direction*)[touch view];
}