Strict Type Checking in Objective-C Part 2

前端 未结 2 1614
遥遥无期
遥遥无期 2020-12-19 21:09

In this question I was looking for a way to ensure that a variable is of a certain type using a define. But sometimes I have this situation:

- (void) theSitu         


        
2条回答
  •  庸人自扰
    2020-12-19 21:41

    When you get the arguments of a method (using method_copyArgumentType as mentioned in the other answer), the "type" it returns is either a C type (like int, float, etc) or just Object (returned as a "@"). Sadly it's not possible to get the objective-C type that a method is expecting — that information is lost when you compile.

    Answer to a similar problem found here.

提交回复
热议问题