我需要在“id =”
之后添加字符串@“d”示例=
url = @"id=63488320543140151742289377"
需要
url = @"id=d63488320543140151742289377"
我试过这个:
NSRange range = [url rangeOfString:@"id="];
[url stringByReplacingCharactersInRange:range withString:@"id=d"];
但没有工作
答案 0 :(得分:7)
url = [url stringByReplacingOccurrencesOfString:@"id=" withString:@"id=d"];
答案 1 :(得分:2)
stringByReplacingCharactersInRange
返回一个字符串。如果您将返回的新字符串分配给某个变量(例如url = [url stringByReplacingCharactersInRange:range withString:@"id=d"];
)