GPS 작업 11

1. 시계의 추가

.h

    NSCalendar*         calendar;

    NSDateComponents*   comps;

추가

.m

초기화 부분

       //날짜 정보 초기화

        calendar= nil;

        comps = nil;

        // 오브젝트 대입

        calendar = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];

구현부

    //날짜 처리

    //날짜 콤포넌트 취득

    unsigned int unitFlag= NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit|NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit;

    comps=[calendar components:unitFlag fromDate:[NSDate date]];

    

    

    // 날짜 표시

//    dateView.text = [NSString stringWithFormat:@”%02d.%02d.    %02d:%02d.%02d “,comps.month,comps.day,comps.hour,comps.minute,comps.second];

    

    [dateLabel setString:[NSString stringWithFormat:@”%02d.%02d.    %02d:%02d.%02d “,comps.month,comps.day,comps.hour,comps.minute,comps.second]];

    NSLog(@”%02d.%02d.    %02d:%02d.%02d “,comps.month,comps.day,comps.hour,comps.minute,comps.second);

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.