views:

446

answers:

1

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

+1  A: 
  1. Create an instance of NSDateFormatter.
  2. Configure the date formatter so that it understands the format you want it to parse (setDateFormat:, setTimeFormat:).
  3. Call the date formatter's -dateFromString: method.
Ole Begemann
all xml paresed contents are saved by([currentElement isEqualToString:@"pubDate"]) { [currentDate appendString:string];how should i append?
Warrior
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
Thanks it really works
Warrior