How to concatenate two strings on iPhone?

后端 未结 6 1171
既然无缘
既然无缘 2021-02-02 17:27

How to connect string \"Hello\" and string \"World\" to \"HelloWorld\"? Looks like \"+\" doesn\'t work.

6条回答
  •  野性不改
    2021-02-02 18:12

    there's always NSMutableString..

    NSMutableString *myString = [NSMutableString stringWithString:@"Hello"];
    [myString appendString: @"World"];
    

    Note:

    NSMutableString *myString = @"Hello"; // won't work, literal strings aren't mutable
    

提交回复
热议问题