且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将字符串转换为NSDate

更新时间:2022-06-23 05:30:13

代码如下,

for(int index=0;index<[DateTimeArray count];index++)
{
   NSDateFormatter *df = [[NSDateFormatter alloc] init];
   [df setDateFormat:@"HH:mm:ss"];
   NSString *timeString=[[[DateTimeArray objectAtIndex:index]componentsSeparatedByString:@" "]objectAtIndex:1];
   NSDate *time=[df dateFromString:timeString];
   [timeArray addObject:time];
   [df release];
}