0

Here's what I'm trying to do:

I'm attempting to pass a string from a UITableView selection into a web service and return a data set. When I hard code the parameter, the code works fine. When using the code below, I get this error:

-[NSCFString stringByReplacingOccurencesOfString:withString:]: unrecognized selector sent to instance 0x6054

-(void) getStateData 
{
    stateWebService = [[NSMutableData data] retain];
    NSMutableURLRequest *request = [[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.**********.com/webservices.asmx/getCGbyState?"]] retain];
    //[request appendString:_Campground.country];
    NSString *country = [_Campground.country stringByReplacingOccurencesOfString:@" " withString:@""];
    [request setHTTPMethod:@"POST"];
    NSString *postString = (@"country=%@",country);
    [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
    NSURLConnection *myConnection = [NSURLConnection connectionWithRequest:request delegate:self];
    [myConnection start];
}
Till
  • 27,559
  • 13
  • 88
  • 122
tallybear
  • 417
  • 3
  • 17

3 Answers3

3

You have a missing 'r' in stringByReplacingOccurencesOfString. It should be stringByReplacingOccurrencesOfString.

Krishna K
  • 708
  • 3
  • 10
  • Yeah. Thanks. Lol. I figured it out right before I saw this. – tallybear Jan 06 '12 at 20:32
  • Man, how do see something like that, Eagle eyes for sure! – Hubert Kunnemeyer Jan 06 '12 at 20:52
  • Well Google helped me out :) I wanted to check on the documentation for the method and see if it had anything to with the error and searched for `stringByReplacingOccurencesOfString`, and the all seeing Big G said _Showing results for stringByReplacingOccurrencesOfString Search instead for stringByReplacingOccurencesOfString_ End of story :) – Krishna K Jan 06 '12 at 21:02
  • to easy I actually had to past one under the other and notice one was sorter than the other and double check every letter to come up with it. – Vincent Bernier Jan 06 '12 at 21:07
1

You are missing a "r" in stringByReplacingOccurrencesOfString

occurrences take 2 "r"

Vincent Bernier
  • 8,674
  • 4
  • 35
  • 40
0

Where is _Campground.country defined? It is potentially getting released before you are calling stringByReplacingOccurencesOfString:withString: on it.

You can enable zombie objects to see what 0x6054 actually is.

Community
  • 1
  • 1
Chris Wagner
  • 20,773
  • 8
  • 74
  • 95