if ([yourString rangeOfString:@"30"].location==NSNotFound)
{
yourString = [yourString stringByReplaceOccurenceOfString:@"30" withString@"60"];
}
Вопрос
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?
Решение 2
if ([yourString rangeOfString:@"30"].location==NSNotFound)
{
yourString = [yourString stringByReplaceOccurenceOfString:@"30" withString@"60"];
}
Другие советы
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"];