NSNumber *Days, *Hours, *Minutes;
// Get the info about a process
NSProcessInfo * processInfo = [NSProcessInfo processInfo];
// Get the uptime of the system
NSTimeInterval UptimeInterval = [processInfo systemUptime];
// Get the calendar
NSCalendar *Calendar = [NSCalendar currentCalendar];
// Create the Dates
NSDate *Date = [[NSDate alloc] initWithTimeIntervalSinceNow:(0-UptimeInterval)];
unsigned int unitFlags = NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit;
NSDateComponents *Components = [Calendar components:unitFlags fromDate:Date toDate:[NSDate date] options:0];
// Get the day, hour and minutes
Days = [NSNumber numberWithLong:[Components day]];
Hours = [NSNumber numberWithLong:[Components hour]];
Minutes = [NSNumber numberWithLong:[Components minute]];
如何获得ios系统持续运行时间
最新推荐文章于 2023-10-12 09:55:58 发布