UIViewController, multiple text fields, and getting rid of the keyboard

I have a UIViewController that has a number of UITextField subviews. In Cocoa for iPhone, I was unable to find a way to determine what the current UIResponder is in order to dismiss it properly, so I wrote this bit of code to iterate through the subclasses of the view, and resign the text field that is currently being edited.

One thing that is notable here is introspection, where once we have the object, we ask it if it is a KindOf UITextField. If so, we know that we can send it the messages 'isEditing' and 'resignFirstResponder'.

There are, of course, some other pieces to this puzzle, such as when this is called. I call this function whenever we want to get rid of any keyboard that may be visible, in this case, I call within a touchesBegan callback from the top level UIViewController.

- (void) dismissAnyKeyboard {
	NSArray *subviews = [self.view subviews];
	for (UIView *aview in subviews) {
		if ([aview isKindOfClass: [UITextField class]]) {
			UITextField *textfield = (UITextField *)aview;
			if ([textfield isEditing]) {
				[textfield resignFirstResponder];