First of all, your expression ...
In Objective-C, we could easily set the current date to an NSString, for example string = [NSDate date];
This is complete trash.
In Objective-C, you need to use NSDateFormatter to output an NSString from an NSDate .
You would do something like this ...
NSDate *date = [NSDate date]; NSDateFormatter *df = [[NSDateFormatter alloc] init]; df.dateStyle = NSDateFormatterMediumStyle NSString *string = [df stringFromDate:date];
Now, in Swift, it is not surprising that this is EXACTLY the same.
let date = NSDate() let dateFormatter = NSDateFormatter() dateFormatter.dateStyle = .MediumStyle let string = dateFormatter.stringFromDate(date)
source share