@scj643 because it doesn't know. The objc runtime can only get the expected type encoding of an argument or a method's return value. The type encoding specifies which primitive type an argument should be (float/int/char/etc) or whether it is an object. But since ObjC classes are basically just glorified structs, the runtime can't differentiate between different classes. (That's why objc has the id type to represent "any objc-object")

@scj643 it says that the type error is caused by the 3rd argument (which makes sense since 1 is self and 2 is cmd).
And it can't say which type it wants because it doesn't know what to expect, it just knows that what it got was wrong

Actually, since objc_util is setting up the ctypes call (based on the method encoding), it does know the types that are needed. For instance, you can copy objc_util and make the following changes (two places, in ObjCClassMethod and ObjCinstanceMethod) where the objc_msgSend calls are: