ios - how to convert string date to nsdate using formatter? -
i follow stackoverflow answer , write code don't know happen.it won't work. plz,any 1 can solve me. use fooling code....
nsmutablearray *moviedate; nsarray *temp1 = [_dicupcomingmovie objectforkey:@"results"]; (nsdictionary *temp2 in temp1) { nsdateformatter *formatter = [[nsdateformatter alloc]init]; nsstring *datestring = [temp2 valueforkey:@"release_date"]; //nsdate *mydate = [[nsdate alloc]init]; [formatter setdateformat:@"dd mmm,yyyy"]; nsdate *date = [formatter datefromstring:datestring]; nslog(@"%@",date); [moviedate addobject:date]; nslog(@"%@",moviedate); }
so it. above code not work mydate object still nil
i believe datestring
doesn't match format specified. see nsdateformatter
complete example.
Comments
Post a Comment