gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 19:21:07 25 4
gpt4 key购买 nike

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

我正在尝试将字符串从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com