Change spaces to plus signs? - Cocoa

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

  1. macrumors newbie

    Joined:
    Jul 6, 2009
    Messages:
    14
    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. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    Messages:
    14,249
    #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. macrumors newbie

    Joined:
    Jul 6, 2009
    Messages:
    14
    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