Problem with iOS Dev: Date Formatting
I have this code:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setTimeStyle:kCFDateFormatterNoStyle];
[dateFormatter setTimeZone:[NSTimeZone localTimeZone]];
NSString 开发者_JAVA技巧*dateAdded = [dateFormatter stringFromDate:[NSDate date]];
[t appendFormat:@" (added at %@)", dateAdded];
t is a NSMutableArray.
I don't know what's wrong with it but the result is dateAdded turned out to be a empty string. If I replace the last line with
[t appendFormat:@" (added at %@)", [NSDate date]];
everything goes just fine, except date is output in raw form.
But what's wrong with my formatting?
Try setting the date style to something other than kCFDateFormatterNoStyle.
精彩评论