1. celebi23's Avatar
    I've got two problem left with my app that I can't figure out. Looked through all of the documentation & can't seem to find the answer.

    1) Can't search more than 1 word queries. Here's the code that I have for searching a site

    - (void)searchBarTextDidEndEditing:(UISearchBar *)mySearchBar
    	// start your search!
    	UIApplication *app = [UIApplication sharedApplication];
    	NSString *nameString = self.mySearchBar.text;
    	NSString *urlString = [NSString stringWithFormat:@"Site that I am searching", nameString];
    	NSURL *url = [NSURL URLWithString:urlString];
    	[app openURL:url];
    When I emailed Apple's Dev Tech Support, they said
    I think you might need to precent-escape all spaces when constructing the URL for searching (%20) should be replaced by the space. There are APIs in NSURL
    and NSString that help you do this.
    I looked all through any documentation relating to NSURL & NSString & couldn't find anything related to that.

    2) And when I do have a valid query entered, any other buttons on the app, like a button to the "About" page, initializes the search process.

    Apple Dev Tech Support suggested this
    Set some break points in your code and find out who is starting the search.
    How exactly would I do that? Any help relating to either problem would be greatly appreciated
    2008-06-27 08:55 PM
  2. NetMage's Avatar
    You should look at NSString stringByAddingPercentEscapesUsingEncoding: to convert the spaces and other characters illegal in URLs (such as ampersand) into their percent equivalents.
    Starlight Computer Wizardry
    Pocket-sized Development
    Follow me on twitter: @NetMage
    2008-06-28 10:34 PM