Question

I have string something like @"goodhouse=30&app=60&val=30askldkla" How can I found the value 30 between house= and &, and change it on 50?

Was it helpful?

Solution 2

if ([yourString rangeOfString:@"30"].location==NSNotFound) {
yourString = [yourString stringByReplaceOccurenceOfString:@"30" withString@"60"];

}

OTHER TIPS

You can find a range between house= and & string using NSRange. And if range exists, then change the string which you want.

try like this,

string=@"30";
str=[str stringByReplaceOccurenceOfString:string withString@"50"];

EDIT:- try like this,

NSString *test = [dateandtime stringByReplacingCharactersInRange:NSMakeRange(10,2) withString:@"50"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top