I'm trying to use NSClassFromString to prevent a block of code from running on pre iOS 3.2 devices. The code block in question is as follows:
if (NSClassFromString(@"UITapGestureRecognizer"))
{
UITapGestureRecognizer *tap = [[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(dismissKeyboard)] autorelease];
[tap setCancelsTouchesInView:NO];
[[self view] addGestureRecognizer:tap];
}
I'm doing this because Apple's documentation states that UITapGestureRecognizer is incompatable with pre 3.2 installations. https://developer.apple.com/library/ios/#documentation/uikit/reference/UITapGestureRecognizer_Class/Reference/Reference.html
I originally thought that using NSClassFromString would return nil when I ran it on this device, but it does not. The statement is true and the code executes. (An interesting note, the code sort of works on a pre 3.2 installation.)
Anyway, I'd like to know why NSClassFromString is NOT returning nil, and is there anything I can do otherwise to accomplish what I'm trying to do?