Why does this message not return a string:
NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *formattedDate = (@"Date for today %@:", [dateFormatter stringFromDate:today]);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That expression does return an NSString, but without formatting. To format an NSString properly, you use the
+stringWithFormat:method:The expression
a, bis a “comma expression“. It will evaluateaandbin sequence, and return the value ofb. In you case, it will return the string of date only.Most of the case, you do not want to use a comma expression.
Also, the
dateFormatterneeds to be configured before using. For instance,