NSString *locations=[[NSString alloc] init];
locations=[mainView getLocationText];
NSMutableArray *cs=[NSMutableArray arrayWithArray:[locations componentsSeparatedByString:@","]];
NSString *city=[[cs objectAtIndex:0] replaceOccurrencesOfString:@" " withString:@"+" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[[cs objectAtIndex:0] length])];
NSString *state=[[cs objectAtIndex:1] replaceOccurrencesOfString:@" " withString:@"+" options:NSCaseInsensitiveSearch range:NSMakeRange(0,[[cs objectAtIndex:0] length])];
NSMutableString *otherParams = [[[NSMutableString alloc] initWithFormat:@"city=%@&state=%@&beds=%@&baths=%@&minprice=%@&maxprice=%@&searchType=%@&page=1",city,state,bedsVal,bathsVal,minPriceVal,maxPriceVal,propTypeVal] autorelease];
它给人的错误取代:在字与字之间除去空间和“+”
Attempt to mutate immutable object with replaceOccurrencesOfString:withString:options:range:'
和空格不与“+”
这是无关紧要的 - 提问者使用'[NSMutableArray arrayWithArray];'创建可变数组。将不可变数组传递给此方法会返回一个新的可变数组,其中包含传入数组的内容。 – Jasarien 2011-06-03 09:38:26
+1 Jasarien,你是对的 - 我得到了一个错误没有我:)我已经改变了我的答案,以反映你的正确答案 – theiOSDude 2011-06-03 09:58:54