Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 如何添加到目标c中的可变字符串?_String_Character_Add_Mutable - Fatal编程技术网

String 如何添加到目标c中的可变字符串?

String 如何添加到目标c中的可变字符串?,string,character,add,mutable,String,Character,Add,Mutable,在不涉及实际程序的太多细节的情况下,我希望获取一个现有字符串并向其添加更多字符(或字符串)。如果这是在java中完成的,它将是这样的 String x=“你好” x=x+“世界” 我现在让我的字符串尝试这样做。我声明的字符串名为whatiscorrect,它现在是一个空字符串,在本例中,我希望获取现有字符串并向其添加一个“o” _whatiscorrect=[[u whatiscorrect stringByAppendingString:@“o”];//在字符串中放置一个o 我该怎么做?你的想

在不涉及实际程序的太多细节的情况下,我希望获取一个现有字符串并向其添加更多字符(或字符串)。如果这是在java中完成的,它将是这样的

String x=“你好”

x=x+“世界”

我现在让我的字符串尝试这样做。我声明的字符串名为whatiscorrect,它现在是一个空字符串,在本例中,我希望获取现有字符串并向其添加一个“o”

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


我该怎么做?

你的想法是对的。只要这样做:

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