The accepted answer seems a little dangerous. From the docs (emphasis mine)
A selector that identifies the method to invoke. The method should not have a significant return value and should take a single argument of type id, or no arguments.
This selector takes two arguments and the argument is a primitive not an id
. So this appears to be working by coincidence...
A safer way that I think reads better as you call the method in the normal way but just use gcd for scheduling:
__weak __typeof(alertView) weakAlertView = alertView;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakAlertView dismissWithClickedButtonIndex:0 animated:YES];
});