NSLOG如何在一行中显示多个变量

时间:2017-07-01 14:02:37

标签: objective-c nslog

我有三个NSString变量   NSString *text1; NSString *text2; NSString *text3; NSLog(@"%@"text1, text2, text3);
这只显示text1变量 如何在一行中在NSLog中显示所有这些?

由于

2 个答案:

答案 0 :(得分:4)

为每个字符串使用%@格式说明符:

NSLog(@"%@ %@ %@", string1, string2, string3);

答案 1 :(得分:-2)

亲爱的使用NSLOG FORMATER VARIABLE SPECIFIER

int i = 5;
float f = 5.3;
double d = 66.76;
long int li = 22;
short int si = 12;
char c = ‘W’;
signed int sint = 34;
unsigned int uint = –23;
int o = 024;
int h = 0xAD;
long long ll = 45;
long double lf = 34.5;
unsigned long long ull = 12;
NSString *msg = @”NSLog Message”;

//  DO NSLOG

NSLog(@” print int %d”, i);
NSLog(@” print float %f”, f); // use %e for exponential
NSLog(@” print double %f”, d); // use %e for exponential
NSLog(@” print long int %li”, li);
NSLog(@” print short int %i”, si);
NSLog(@” print char %c”, c);
NSLog(@” print signed int %i”, sint);
NSLog(@” print unsigned int %u”, uint);
NSLog(@” print octal %o”, o);
NSLog(@” print hexadecimal %X”, h);
NSLog(@” print long long %lld”, ll);
NSLog(@” print long double %Lf”, lf);
NSLog(@” print unsigned long long %llu”, ull);
NSLog(@” print Object %@”, msg);