//
//  SearcherViewController.m
//  Searcher
//
//  Created by Bill Dudney on 12/27/08.
//  Copyright Gala Factory Software LLC 2008. All rights reserved.
//
//
//  Licensed with the Apache 2.0 License
//  http://apache.org/licenses/LICENSE-2.0
//

#import "SearcherViewController.h"

@implementation SearcherViewController

//START:code.searcher.tfShouldReturn
- (BOOL)textFieldShouldReturn:(UITextField *)field {
  [field resignFirstResponder];
	return YES;
}
//END:code.searcher.tfShouldReturn

//START:code.searcher.openSafari
- (void)textFieldDidEndEditing:(UITextField *)field {
  NSString *query = @"iPhone";
  if(field.text != nil && [field.text length]) {
    query = field.text;
  }
  NSString *urlString = [NSString stringWithFormat:@"http://google.com?q=%@",
                         query];
  NSURL *url = [NSURL URLWithString:urlString];
  [[UIApplication sharedApplication] openURL:url];
}
//END:code.searcher.openSafari

@end
