mardi 26 juillet 2016

how to convert string date to nsdate using formatter?

i follow stackOverflow answer and Write a code but i Don't know What happen.it won't work. plz,any one can solve it for me. i use fooling code....

        NSMutableArray *movieDate;
    NSArray *temp1 = [_dicUpcomingMovie objectForKey:@"results"];
    for (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 this is it. the above code was not work myDate object still nil

Aucun commentaire:

Enregistrer un commentaire