在不深入了解实际程序的情况下,我想获取一个现有的字符串并向其中添加更多字符(或多个字符串)。如果这是用Java完成的,它将是这样

字符串x =“hello”

x = x +“world”;

我目前有我的字符串试图这样做。我声明的字符串称为_whatiscorrect,它现在是一个空字符串,在此示例中,我想使用现有字符串并在其中添加一个“o”。

_whatiscorrect = [_whatiscorrect stringByAppendingString:@“o”]; //在字符串中放置一个o

我该怎么做呢?

最佳答案

你有正确的主意。只是这样做:

NSMutableString * _whatiscorrect = [[NSMutableString alloc] initWithString: @".."];
[_whatiscorrect appendString:@"o"];

09-26 22:10
查看更多