Is there a way (an elegant way that is) to extract a date format from a string containing a date so that it may be converted into an NSDate via NSDateFormatter?
i.e
string = @"2011-1-10";
format = [extractor extractFormat:str开发者_C百科ing];// format would = yyyy-dd-mm
[formatter setDateFormatter:format];
NSDate * date = [formatter dateFromString:string];
If that is the only information you have then it is impossible. For example, "10-10-10".
精彩评论