The method you're looking for is +[NSDateFormatter dateFormatFromTemplate:options:locale:]
.
This method is specifically for "localizing" a date format into a desired locale.
For example, if you want to know the user's preferred year-month-day format, you do:
NSString *fmt = [NSDateFormatter dateFormatFromTemplate:@"dMMMMy" options:0 locale:[NSLocale currentLocale]];
Or if you want to know their preferred time format, you do:
NSString *fmt = [NSDateFormatter dateFormatFromTemplate:@"jm" options:0 locale:[NSLocale currentLocale]];
You use this method when you need the actual format string. If you just want to format a date according to the predefined styles (long, full, medium, short), then you use the constants as explained in a couple of the other answers.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…