Objective-C dynamic_cast?

前端 未结 3 660
不思量自难忘°
不思量自难忘° 2020-12-05 11:19

Is there an Objective-C equivalent of C++\'s dynamic_cast?

It can be faked using this:

MyClass *safeObject = [object isKindOfClass: [MyClass class]]
         


        
3条回答
  •  余生分开走
    2020-12-05 12:14

    1. I don't think there is.
    2. I think the space for a bug is quite small here.
    3. But if you insist, a macro will do fine?

提交回复
热议问题