-2

i'm trying to append two NSMutablestring, but i want to make the comma separation between them. Right now the code i use is this:

NSString *astring = @"This is a string";
teststring = [[NSMutableString alloc]init];
[teststring appendString:astring];
NSLog(@"%@",teststring);

the result is :This is a stringThis is a String

i try with:

[teststring appendFormat:@",%@",astring];

but still no luck.

Please help, regards.

user2373192
  • 31
  • 1
  • 5

4 Answers4

0

I used this and its working fine for me :

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

Nishant Tyagi
  • 9,893
  • 3
  • 40
  • 61
0
  teststring = [[NSMutableString alloc]init];
 [teststring appendString:@","];
  [teststring appendString:astring];
iTag
  • 413
  • 1
  • 4
  • 10
0

Try this

NSString *astring = @"This is a string";
teststring = [[NSMutableString alloc]init];

[teststring appendString:astring];
[teststring appendString:@","];
[teststring appendString:astring];

NSLog(@"%@",teststring);
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

Try this

NSString *string = @"Hello World";

NSMutableString * secondstring =[[NSMutableString alloc]init];

[secondstring appendString:string] 
[secondstring appendString:@","];
[secondstring appendString:string];

If you want to see this String

NSLog(@"%@",secondstring);
Jitendra
  • 5,055
  • 2
  • 22
  • 42