我正在尝试附加两个NSMutablestring,但我想让它们之间的逗号分隔。现在我使用的代码就是:
NSString *astring = @"This is a string";
teststring = [[NSMutableString alloc]init];
[teststring appendString:astring];
NSLog(@"%@",teststring);
结果是:这是一个字符串这是一个字符串
我尝试:
[teststring appendFormat:@",%@",astring];
但仍然没有运气。
请帮忙,问候。
答案 0 :(得分:0)
我用过这个,它对我来说很好用:
NSMutableString *teststring = [[NSMutableString alloc]init];
NSMutableString *astring = [[NSMutableString alloc]init];
[astring appendString:@"I am appending this string"];
[teststring appendFormat:@",%@",astring];
NSLog(@"string : %@",teststring);
O / P: string : ,I am appending this string
答案 1 :(得分:0)
teststring = [[NSMutableString alloc]init];
[teststring appendString:@","];
[teststring appendString:astring];
答案 2 :(得分:0)
试试这个
NSString *astring = @"This is a string";
teststring = [[NSMutableString alloc]init];
[teststring appendString:astring];
[teststring appendString:@","];
[teststring appendString:astring];
NSLog(@"%@",teststring);
答案 3 :(得分:0)
试试这个
NSString *string = @"Hello World";
NSMutableString * secondstring =[[NSMutableString alloc]init];
[secondstring appendString:string]
[secondstring appendString:@","];
[secondstring appendString:string];
如果你想看到这个字符串
NSLog(@"%@",secondstring);