iPhone Objective-C foreach design

前端 未结 2 1421
迷失自我
迷失自我 2021-02-19 16:20

I\'m trying to implement a design as follows:

Touch class : acts as an interface, several classes inherit from it:
MoveTouch class

2条回答
  •  星月不相逢
    2021-02-19 16:53

    You need to test for the class type:

    for (Touch *t in touches) {
      if ([t isKindOfClass:[MoveTouch class]]) {
        MoveTouch *mt = (MoveTouch *)t;
        // do what you want with mt
      }
    }
    

提交回复
热议问题