Results 1 to 2 of 2

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.

Thread: Got some questions about urlString...

  1. #1
    Default Got some questions about urlString...
    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

  2. #2
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts