OSRequiredCast
Casts the object to the specified type, stopping the process if the object isn’t of the correct type.
Declaration
#define OSRequiredCast(type, inst)Parameters
- type:
The name of the desired class type as a raw token, not as a string or macro.
- inst:
The object to cast to the specified type.
Return Value
The object cast to the specified type.
Discussion
Use this macro when you require the object to be the specified type, and you are sure that it’s the specified type. The following example shows how to cast some object to the OSString class. If the object cannot be cast to a string, the macro terminates the process.
OSString string = OSDynamicCast(OSString, anObject)