MagicMiles MagicMiles - 1 year ago 141
Objective-C Question

Concatenate Multiple TEXT and Variables into one string iOS?

I'm trying to figure out what is wrong with what I believe is simple concatenation, and I must be missing something here - see code below:

NSString *combinedValues = [NSString stringWithFormat:
@"I am at %@" self.dancePlace.text
@" Airport, and I will arrive on %@" danceDateValue,
@" from %@" timeIn,
@" to %@" timeOut,
@" at Terminal %@" self.danceTerminal.text
@" Gate %@" self.danceGate.text];

Answer Source

this is a good way

NSString *combinedValues = [NSString stringWithFormat:
                            @"I am at %@ Airport, and I will arrive on %@ from %@ to %@ at Terminal %@ Gate %@" , self.dancePlace.text, danceDateValue, timeIn, timeOut, self.danceTerminal.text, self.danceGate.text];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download