Reputation: 1926
I have two UITextViews:
self.itemsTextView.text;
self.priceTextView.text;
I want to concatenate these two like so:
NSString *data = self.textView.text + self.itemsTextView.text;
I have tried using a colon, as suggested by this thread, but it doesn't work.
NSString *data = [self.textView.text : self.itemsTextView.text];
Upvotes: 0
Views: 493
Reputation: 318804
There are so many ways to do this. In addition to the stringWithFormat:
approaches of the other answers you can do (where a
and b
are other strings):
NSString *c = [a stringByAppendingString:b];
or
NSMutableString *c = [a mutableCopy];
[c appendString b];
Upvotes: 0
Reputation: 1753
You may use
NSString * data = [NSString stringWithFormat:@"%@%@",self.textView.text,self.itemsTextView.text];
Upvotes: 1
Reputation: 46543
For concatenating you have several options :
Using stringWithFormat:
NSString *dataString =[NSString stringWithFormat:@"%@%@",self.textView.text, self.itemsTextView.text];
Using stringByAppendingString:
NSMutableString has appendString:
Upvotes: 2