KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I know that the NSDateformatter suite of functionality is a boon for mankind, but at the same time it is very confusing to me. I hope you can help me out. Somewhere in my code, there is an int representing a month. So: 1 would be January, 2 February, etc. In my user interface, I would like to display this integer as proper month name. Moreover, it should adhere to the locale of the device. Thank you for your insights In the mean time, I have done the following: int monthNumber = 11 NSString * dateString = [NSString stringWithFormat: @"%d", monthNumber]; NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM"]; NSDate* myDate = [dateFormatter dateFromString:dateString]; [dateFormatter release]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MMMM"]; NSString *stringFromDate = [formatter stringFromDate:myDate]; [formatter release]; is this the way to do it? It seems a bit wordy.
Tags (comma-separated)
Save Edits
Cancel