0
배열에서 문자열 형식으로 저장되는 배열에서 날짜를 거의 가져 오지 않았습니다. 이제 다시 날짜 시간을 OO로 변경하고 싶습니다. OO : OO : 검색하고 가져올 때만 time..My 코드가없는 날짜가 ..NSDate를 특정 시간으로 설정하기
내가 올바른 방법 뭐하는거야 아니면 내가 뭔가를 놓친 거지 여부for(int i = 0 ; i<[keys count]; i++)
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeStyle = NSDateFormatterNoStyle;
dateFormatter.dateFormat = @"dd-MMM-yyyy";
NSDate *noteDate = [dateFormatter dateFromString:[keys objectAtIndex:i]];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit | NSYearCalendarUnit | NSMonthCalendarUnit)fromDate:[NSDate date]];
NSInteger year = [weekdayComponents year];
//NSInteger month = [weekdayComponents month];
[gregorian setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
NSDateComponents *timeZoneComps=[[NSDateComponents alloc] init];
[timeZoneComps setYear:year];
[timeZoneComps setHour:00];
[timeZoneComps setMinute:00];
[timeZoneComps setSecond:01];
NSDate *noteDate1 =[gregorian dateFromComponents:timeZoneComps];
[self saveNotes:0 :noteDate1 :notes];
NSLog(@"dates:%@",noteDate);
}
아래로, 나 좀 도와 친구하시기 바랍니다있다
감사 란짓