How do I add a space between two concatenated NSStrings?

Posted by ChrisR on Stack Overflow See other posts from Stack Overflow or by ChrisR
Published on 2009-03-22T17:55:36Z Indexed on 2010/05/21 4:10 UTC
Read the original article Hit count: 302

Filed under:
|

I have three string objects:

NSString *firstName;
NSString *lastName;
NSString *fullName;

The values for firstName and lastName are received from NSTextFields.

I then want to concatenate the two strings and place the result in fullname.

This is the code that I'm using:

fullName = [firstName stringByAppendingString:lastName];

However, the result does not put a space between the two names (e.g. JohnSmith).

How do I add in the space? I'd like the result to look like (John Smith).

© Stack Overflow or respective owner

Related posts about nsstring

Related posts about concatenation