iphone - 收到无法识别的选择器错误

标签 iphone ios web-services nsstring

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

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

-[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];
}

最佳答案

stringByReplacingOccurencesOfString 中缺少“r”。它应该是 stringByReplacingOccurrencesOfString

关于iphone - 收到无法识别的选择器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8763741/

相关文章:

ios - 删除重新排序的 UITableViewCells 后应用程序崩溃

php - 使用现有的 Laravel Controller 编写 Web 服务

ios - 在iOS上设置默认 session 长度?

iphone - 手势识别器未激活 - UIScrollView 内的 UIImageView

ios - quickblox webrtc视频通话接收方法未被调用

ios - Swift:如何知道谷歌地图的右上角和左下角坐标

ios - 向 App Transport xcode 8 添加临时异常(exception)

django - 使用 SSL (https) 的网络服务的 Nginx 设置

java - 如何获取 Web 服务异常的原因

iphone - 从 iPhone 获取一般信息