Zol*_*olt 3 string xcode integer concatenation objective-c
请原谅问题的简单性.我对Objective C完全不熟悉
我想知道如何连接整数和字符串值并将它们打印到控制台.
这就是我想要输出的内容:
10 + 20 = 30
Run Code Online (Sandbox Code Playgroud)
在Java中,我编写此代码以生成所需的结果:
System.Out.Println(intVarWith10 + " + " + intVarWith20 + " = " + result);
Run Code Online (Sandbox Code Playgroud)
Objective-C完全不同.我们如何连接3个整数以及它们之间的字符串?
小智 5
您可以使用以下代码
int iFirst,iSecond;
iFirst=10;
iSecond=20;
NSLog(@"%@",[NSString stringWithFormat:@"%d + %d =%d",iFirst,iSecond,(iFirst+iSecond)]);
Run Code Online (Sandbox Code Playgroud)