I have two textfield
and one label, say Txt1 and Txt2 and result, i want to add both input of text field and display it on one label in same view controller.
So how can i do this? Thank you.
Asked
Active
Viewed 1,235 times
0
-
1NSString *result =[NSString StringWithFormat:@"%@ %@", Txt1.text, Txt2.text]; label.text=result; – Gagan_iOS Mar 10 '16 at 12:31
-
Thanks it really worked :) – Arjun Ker Mar 10 '16 at 12:40
-
@Arjun Ker please first R&D on stackoverflow than ask question. Thanks your solution is here http://stackoverflow.com/questions/510269/shortcuts-in-objective-c-to-concatenate-nsstrings – Ilesh P Mar 10 '16 at 12:40
-
Arjun ker please refer my answer. – user3182143 Mar 10 '16 at 12:41
2 Answers
1
Try this :
@IBOutlet var label: UILabel!
@IBOutlet var txt2: UITextField!
@IBOutlet var txt1: UITextField!
//Setting value t label
label.text = txt1.text! + txt2.text!

Bhagyalaxmi Poojary
- 1,213
- 1
- 12
- 17
0
yourLabel.text = [NSString stringWithFormat:@"%@%@",txtField1.text,txtField2.text];

user3182143
- 9,459
- 3
- 32
- 39