如何在iPhone上连接两个字符串? [英] How to concatenate two strings on iPhone?
本文介绍了如何在iPhone上连接两个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将字符串Hello和字符串World连接到HelloWorld?看起来像+不起作用。
How to connect string "Hello" and string "World" to "HelloWorld"? Looks like "+" doesn't work.
推荐答案
NSString *string = [NSString stringWithFormat:@"%@%@", @"Hello", @"World"];
NSLog(@"%@", string);
这应该可以解决问题,虽然我确信有更好的方法可以做到这一点,只需要记忆我也必须说这是未经测试的所以请原谅我。最好的办法是找到NSString的stringWithFormat文档。
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.
这篇关于如何在iPhone上连接两个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文