I am new to iphone development .I have parsed a xml page and stored the title, date, summary, in a mutable array "stories" as mutable dictionary "object for key".All the values are saved as string But i want to save the Date value as date format.So that i can sort it with date.How can i achieve that.Please help me out.Thanks
views:
446answers:
1
+1
A:
- Create an instance of
NSDateFormatter
. - Configure the date formatter so that it understands the format you want it to parse (
setDateFormat:
,setTimeFormat:
). - Call the date formatter's
-dateFromString:
method.
Ole Begemann
2010-02-20 14:59:38
all xml paresed contents are saved by([currentElement isEqualToString:@"pubDate"]) { [currentDate appendString:string];how should i append?
Warrior
2010-02-20 15:21:46
You don't change this code. But when the element has been parsed completely, `currentDate`contains the string you then convert to a NSDate with the date formatter.
Ole Begemann
2010-02-20 16:08:08
Thanks it really works
Warrior
2010-02-20 17:33:17