convert string to date and write back into NSMutableArray

Posted by padatronic on Stack Overflow See other posts from Stack Overflow or by padatronic
Published on 2010-04-29T10:12:10Z Indexed on 2010/04/29 10:17 UTC
Read the original article Hit count: 375

Filed under:
|
|

I have a NSMutableArray I get by loading a plist into it. The date field comes in as a string and i want to change it into a nsdate. I can change an nsstring into an nsdate.

My array is an array of objects like the one below;

{
Date = "1/1/2009"
Description = "Have you ever looked at a badger and thought i wonder how far you could fire that out of a cannon? Well this talk is for you";
File = "http://www.badgerCannon.org.uk/mp3/070310pm.mp3";
Series = "The Badger planet";
Speaker = "Will Ferell";
Title = "Is it a bird, is it a plane? no its a badger";
}

I loop through and pull out the date and convert it from a NSString to a NSDate.

I try writing it back in using the code;

[[self.MediaDataArray objectAtIndex:i] replaceObjectAtIndex:0 withObject:Date];

but it errors and i am pretty sure it is because i am not putting it back into the array in the same format, ie just as a date not as date = "date". But lets face it i don't really know!

Am i barking up the wrong tree? Please help, i have got the coding equivalent of writters block, or alternatively am just being really stupid! thanks in advance

© Stack Overflow or respective owner

Related posts about nsdate

Related posts about iphone