I am looking to convert a NSString to an NSDate and would just like to ask a few questions about this.
The purpose of the conversion is to take a section header in a table view which is a string derived from an NSDate, and to pass it back to a UIDatePicker, so that the date picker can use that date in the string.
I've been reading some posts about this and there are tons of formats to work through.
My string date format is in the form:
March 10, 2014 for American formats and 10 March 2014 for UK formats.
What would I need to do to:
1) Get that date to translate over to the UIDatePicker appropriately 2) Work with different country formats so that the date picker is updated for UK and US users.
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"d-MMMM-YYYY"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:sectionTitle];
dateFromString is currently null.
I've been looking at https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html , Converting NSString to NSDate (and back again) and http://waracle.net/iphone-nsdateformatter-date-formatting-table/ but am not sure how to proceed.
Any assistance would be appreciated on this