这是我正在尝试做的事情:
我正在尝试将字符串从 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/