接收的无法识别的选择错误
这里就是我想要做的事:接收的无法识别的选择错误
我试图从一个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
。
漂亮的老鹰眼睛 – 2012-01-06 20:15:39
是的。谢谢。大声笑。在我看到这个之前,我已经明白了。 – tallybear 2012-01-06 20:32:10
男人,怎么看到这样的事情,鹰眼确定! – 2012-01-06 20:52:03
哪里_Campground.country
定义?在您打电话给stringByReplacingOccurencesOfString:withString:
之前,它可能会被释放。
你can enable zombie objects看什么0x6054
实际上是。
你缺少在stringByReplacingOccurrencesOfString
occurrences
一个 “R” 拿2 “R”
你能提供什么类_Campground是头?我怀疑这个'country'成员可能不是NSString。 – 2012-01-06 20:08:42
这绝对是一个NSString。在Campground.h文件中,我使用NSString * country声明了它; – tallybear 2012-01-06 20:12:01
我明白了......如果我正确拼写Occurrences,这将有所帮助...: -/lol – tallybear 2012-01-06 20:16:41