更新时间:2022-12-27 14:13:54
如果它总是使用相同的字符:
If it is always the same character you can use:
stringByReplacingOccurrencesOfString:withString:
如果它是同一位置的相同字符串,您可以使用:
If it is the same string in the same location you can use:
stringByReplacingOccurrencesOfString:withString:options:range:
如果只是一个特定的位置,你可以使用:
If is just a specific location you can use:
stringByReplacingCharactersInRange:withString:
此处的文档:
https://developer.apple.com/documentati on / foundation / nsstring
例如:
NSString *someText = @"Goat";
NSRange range = NSMakeRange(0,1);
NSString *newText = [someText stringByReplacingCharactersInRange:range withString:@"B"];
newText等于Boat
newText would equal "Boat"