开发者

Strings wont combine - Objective C

开发者 https://www.devze.com 2022-12-31 05:17 出处:网络
Ik have the following strings in the .H file, and i want them to merge into one string at the end of the app when the have collected their data.

Ik have the following strings in the .H file, and i want them to merge into one string at the end of the app when the have collected their data.

It wont work, why开发者_开发百科 not and how must i do it correct so the data collected in these strings will be merged into one string ??

NSString *dataHML; 
NSString *dataHML2;
NSString *dataHML3;
NSString *dataHML4;
NSString *dataHML5;
NSString *dataHML6;
NSString *dataHMLtotal = *dataHML + *dataHML2 + *dataHML3 + *dataHML4 + *dataHML5 + *dataHML6;


NSString *dataHtmlTotal = [NSString stringWithFormat:@"%@%@%@%@%@%@", dataHtml, dataHtml2, dataHtml3, dataHtml4,dataHtml5,dataHtml6];


Objective-C does not support operator overloading so + doesn't do what you want here. You can use: [NSString stringWithFormat:@"%@%@%@%@%@%@", dataHtml, dataHtml2, dataHtml3, dataHtml4, dataHtml5, dataHtml6];

instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消