Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate three string in iphone [closed]

Tags:

xcode

iphone

I have three string and I want them to concatenate but they are not concatenating. I am using this code.

I want my last string to display like this:

Cerenia Results 12Jun 2012.pdf

like this

NSString *fileName = @"Cerenia Results";

NSString* str = [formatter stringFromDate:date]; 

NSString*extention=@".pdf";


NSString * strRR = [NSString stringWithFormat:@"Cerenia Results_%@ [%@].pdf", extension];
like image 262
The Developer Avatar asked Jun 12 '12 10:06

The Developer


1 Answers

General case : to concatenate all three strings you should use

NSString * strRR = [NSString stringWithFormat:@"%@%@%@", fileName, str, extension];

Your case:

You can add any formatting you like such as inserting characters in between (to get the results you are after >> Cerenia Results 12Jun 2012.pdf)

[formatter setDateFormat:@"ddMMMyyyy"]
NSString* fileName = @"Cerenia Results";
NSString* str = [formatter stringFromDate:date];
NSString* extension = @"pdf";
NSString* strRR = [NSString stringWithFormat:@"%@ %@.%@", fileName, str, extension];
like image 51
Future2020 Avatar answered Oct 01 '22 11:10

Future2020