I have the following method. I currently use try/catch blocks to determine whether the argument is a class or a protocol, and it seems like it's causing a memory leak. What's the correct way to determine whether x
is a class or a protocol?
[self _injectMacro:[MyClass class]];
[self _injectMacro:@protocol(MyProtocol)];
+ (id)_injectMacro:(id)x
{
@try {
return NSStringFromProtocol(x);
}
@catch (NSException *exception) {
}
@try {
return NSStringFromClass(x);
}
@catch (NSException *exception) {
}
return nil;
}