how to concatenate values from two Uitextfield into a single string in iphone
I want to take two value from user i.e name and location and then want to concatenate them into single string to produce output string
IBOutlet UITextField *txtName;
IBOutlet UITextField *txtLoc;
Want to concatenate them to produce below string.
Student Name is txtName and He is from txtLoc
Basically that's my complete code.
NSString *message = [NSString stringWithFormat:@"Student Name is %@ from %@ phone Number is%@ and he want to say%", txtName.text, txtLoc.text,txtPho.text,txtBody.text];
-(void) send开发者_如何学Python:(id) sender {
[self sendEmailTo:@"naumankhattak@gmail.com" withSubject:@"Contact for Quran Focus from iphone Application" withBody:message];
That's what I want to do. and em getting error
'txtName' undeclared here(not in a function)
'txtLoc' undeclared here(not in a function) 'txtPho' undeclared here(not in a function) 'txtBody' undeclared here(not in a function)
Though I have correctly declared all outlets.
NSString *result = [NSString stringWithFormat:@"Student Name is %@ and He is from %@", txtName.text, txtLoc.text];
You need to put your message assignment line inside the send: function, just before the call to sendEmailTo:withSubject:withBody:.
NSString *outputString=[NSString stringWithFormat:@"Student Name is %@ and he is from %@",txtName.text,txtLoc.text];
Get the text string from each UITextField ([txtName text]) and use a stringByAppendingString method:
combinedString = [[txtName text] stringByAppendingString:[txtLoc text]]
精彩评论