Occasionally, during development/debugging, I want to ensure that an object is of a certain type:
PageTopBottom *newPage = [notification object];
assert([new
Hmm, with Objective-C++ there are two options:
Write a template function
template void assertType(T* obj) { ... }
For a pointer X* x
, use NSClassFromString([NSString stringWithUTF8String:typeid(*x).name()])
.
Without using C++, you might be able to use GCC extension typeof
, but I'm not sure if [typeof(*x) class]
is a legit operation...