Change spaces to plus signs? - Cocoa

Discussion in 'Mac Programming' started by macindev, Jul 29, 2009.

  1. macindev
    Expand Collapse
    macrumors newbie

    Joined:
    Jul 6, 2009
    Location:
    Seattle, Washington, USA
    #1
    I have no clue how to do this!
    What I want to be done is to have the spaces in a string be changed to plus "+" signs, but I don't know what code would be needed. Can anyone help?
    Thanks in advance.


    For those who want to know, here's my code:

    Code:
    - (void)connectSearch:(id)sender{
    	[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:
    	[@"http://www.google.com/search?q=" stringByAppendingString:[searchQuery stringValue]]]]];
    }
     
  2. gnasher729
    Expand Collapse
    macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2

    In XCode, right-click on the word "stringByAppendingString", select "Show in API Reference" in the popup menu, and read the documentation of the NSString functions.
     
  3. macindev
    Expand Collapse
    thread starter macrumors newbie

    Joined:
    Jul 6, 2009
    Location:
    Seattle, Washington, USA
    #3
    Thank You! I finally got it to work using this
    Code:
    stringByReplacingOccurrencesOfString:(NSString *)replaceString withString:(NSString *)replaceStringWith
    :D
     

Share This Page