How to plus NSString
?
Example:
NSString *a=@"hello";
NSString *b=@"world";
NSString *s=@"";
I want:
s = "helloworld";
Thank for helping.
How to plus NSString
?
Example:
NSString *a=@"hello";
NSString *b=@"world";
NSString *s=@"";
I want:
s = "helloworld";
Thank for helping.
Please use below code.
NSString *s= [NSString stringWithFormat:@"%@%@", a, b];
What you are talking about is concatenating. And you need to use:
NSString *a = @"This ";
NSString *b = @"is a string";
NSString *c= [NSString stringWithFormat:@"%@%@", a, b];
Check out: objective-c strings a guide for beginners for a full list.
You can also use stringByAppendingString:
like so -
NSString *completeString = [a stringByAppendingString:b];
NSString *a=@"hello";
NSString *b=@"world";
NSString *s=[NSString stringWithFormat:@"%@%@", a, b];
NSString *completeString = [a stringByAppendingString:b];
This function is Good and Easy...