How to concatenate two strings on iPhone?

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

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

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-02 18:09

    NSString *string = [NSString stringWithFormat:@"%@%@", @"Hello", @"World"];
    NSLog(@"%@", string);
    

    That should do the trick, although I am sure there is a better way to do this, just out of memory. I also must say this is untested so forgive me. Best thing is to find the stringWithFormat documentation for NSString.

提交回复
热议问题