這裏就是我想要做的事:接收的無法識別的選擇錯誤
我試圖從一個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];
}
你能提供什麼類_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