接收无法识别的选择器错误

时间:2012-01-06 20:02:44

标签: iphone ios web-services nsstring

这是我正在尝试做的事情:

我正在尝试将字符串从UITableView选项传递到Web服务并返回数据集。当我硬编码参数时,代码工作正常。使用下面的代码时,我收到此错误:

  

- [NSCFString stringByReplacingOccurencesOfString:withString:]:无法识别的选择器发送到实例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];
}

3 个答案:

答案 0 :(得分:3)

stringByReplacingOccurencesOfString中缺少'r'。它应该是stringByReplacingOccurrencesOfString

答案 1 :(得分:1)

stringByReplacingOccurrencesOfString

中缺少“r”

occurrences取2“r”

答案 2 :(得分:0)

_Campground.country在哪里定义?在你打电话给stringByReplacingOccurencesOfString:withString:之前,它可能会被释放。

can enable zombie objects了解0x6054实际上是什么。