날짜, 월, 연도를 사용하는 앱을 개발 중입니다. 나는 현재 달이 28,29,30,31 일을 가질 수 있기 때문에 현재 달 날짜를 원한다. 나는 현재 년 개월을 얻으려고 노력했다. 하지만 위의 코드를 모르겠습니다. 여기 내 코드가있다.Objective c에서 현재 달의 날짜를 얻는 방법은 무엇입니까?
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSDate *today = [NSDate date];
NSCalendar *currentCalendar = [NSCalendar currentCalendar];
NSDateComponents *yearComponents = [currentCalendar components:NSYearCalendarUnit fromDate:today];
int currentYear = [yearComponents year];
for(int months = 0; months < 12; months++)
{
NSString *monthName = [NSString stringWithFormat:@"%@ %i",[[dateFormatter monthSymbols]objectAtIndex: months],currentYear];
NSLog(@"%@ %i",[[dateFormatter monthSymbols]objectAtIndex: months],currentYear);
[monthArray addObject:monthName];
}
어떻게 각각의 날짜를 얻을 수 있습니까 ?? 2011 년 1 월 10 일부터 3110-2013까지 – Manimaran
개별 날짜를 얻는 방법이 있습니까? – Isuru
http://stackoverflow.com/questions/8501502/getting-every-nsdate-for-this-month-as-nsstring –