I have this code:
// Fill out the email body text
NSString *emailBody = (@"Name:%@\nNumber of People:\nDate:", name.text);
NSLog(@"%@", emailBody);
As you can see I’m trying to append name.text to the e-mail body just after “Name:”. However, NSLog only outputs the string contained in name.text and none of the rest of the e-mail body. What am I doing wrong here that the code deletes the rest of the string apart from name.text?
E.G if name.text contained the text “Jack”, then NSLog would only output “Jack” and not:
Name: Jack
Number of People: x
Date: x
Which is what I am looking for.
Can anyone give me an insight as to what I’m doing wrong?
Thanks,
Jack
Use +stringWithFormat method:
What you have now is a valid code, but it doesn’t do what you want:
calls a comma operator – it evaluates its 1st parameter, discards it and returns 2nd parameter, so that’s why
emailBodyis eventually filled withname.textvalue