I need to concatenate a NSString with the NSString output of NSDateFormatter. My code is below.
Please check where I am going wrong. I have to concatenate DEST PATH with datestring.
NSDateFormatter * formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"dd-MM-yyyy HH-mm"];
NSString * dateString = [formatter stringFromDate:[NSDate date]];
NSString *DEST_PATH=[NSHomeDirectory() stringByAppendingString:@"/Documents/Movie1];
// below is for concatenate
result =[result stringByAppendingString:DEST_PATH];
result=[result stringByAppendingString:dateString];
It appears as though you never instantiate the
NSStringresult. I would change the above to the following:If you use the
stringByAppendingPathComponentmethod it will automatically add the slash for you.Also, using all capital letters for identifiers usually denotes a c style propocessor macro constant, so using it as a variable may confuse some people.