728x90
NSDate *pastDate = ...;
NSDate *nowDate = [NSDate date]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSUInteger calendarUnit = NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
NSDateComponents *dateComp = [calendar components: calendarUnit fromDate: nowDate toDate: pastDate options:0]; NSInteger day = dateComp.day; NSInteger hour = dateComp.hour; NSInteger min = dateComp.minute; NSInteger sec = dateComp.second;
728x90
'Developer > iOS' 카테고리의 다른 글
[iOS]What's New in the Apple Push Notification Service (0) | 2017.08.08 |
---|---|
iOS의 코드 서명(데이터 실행 보호(DEP - Data Execution Prevention)) (0) | 2017.03.21 |
iOS10.0의 새로운 점(What's New in iOS 10.0) (0) | 2016.11.07 |
비동기(NSOperation, GCD)의 차이점. (2) | 2016.08.16 |
[iOS]WCSession으로 iWatch와 iPhone 데이터 주고 받기 (0) | 2016.08.02 |