我是编程新手。如果设备关闭(关闭),我的应用程序之一需要更新,因此我需要设备关闭时的当前时间。
我知道,我们可以获得系统启动时间(开启时间) [NSProcessInfo processInfo] .systemUptime。
但我需要关掉时间。有没有办法得到它!如果是,请告诉我如何......? 修改:如果否,请让我知道原因......!
我还提到了以下链接。它只给出系统启动时间(开启时间)。 Getting iOS system uptime, that doesn't pause when asleep
如果它在那里,请给我正确的解决方案......!
答案 0 :(得分:0)
在关机时触摸文件。 %touch mytimeToreboot
答案 1 :(得分:-1)
你无法关机。你只能获得ReBoot Time。
Apple仅提供以下详细信息。
#define KERN_OSTYPE 1 /* string: system version */
#define KERN_OSRELEASE 2 /* string: system release */
#define KERN_OSREV 3 /* int: system revision */
#define KERN_VERSION 4 /* string: compile time info */
#define KERN_MAXVNODES 5 /* int: max vnodes */
#define KERN_MAXPROC 6 /* int: max processes */
#define KERN_MAXFILES 7 /* int: max open files */
#define KERN_ARGMAX 8 /* int: max arguments to exec */
#define KERN_SECURELVL 9 /* int: system security level */
#define KERN_HOSTNAME 10 /* string: hostname */
#define KERN_HOSTID 11 /* int: host identifier */
#define KERN_CLOCKRATE 12 /* struct: struct clockrate */
#define KERN_VNODE 13 /* struct: vnode structures */
#define KERN_PROC 14 /* struct: process entries */
#define KERN_FILE 15 /* struct: file entries */
#define KERN_PROF 16 /* node: kernel profiling info */
#define KERN_POSIX1 17 /* int: POSIX.1 version */
#define KERN_NGROUPS 18 /* int: # of supplemental group ids */
#define KERN_JOB_CONTROL 19 /* int: is job control available */
#define KERN_SAVED_IDS 20 /* int: saved set-user/group-ID */
#define KERN_BOOTTIME 21 /* struct: time kernel was booted */
#define KERN_NISDOMAINNAME 22 /* string: YP domain name */
#define KERN_DOMAINNAME KERN_NISDOMAINNAME
#define KERN_MAXPARTITIONS 23 /* int: number of partitions/disk */
#define KERN_KDEBUG 24 /* int: kernel trace points */
#define KERN_UPDATEINTERVAL 25 /* int: update process sleep time */
#define KERN_OSRELDATE 26 /* int: OS release date */
#define KERN_NTP_PLL 27 /* node: NTP PLL control */
#define KERN_BOOTFILE 28 /* string: name of booted kernel */
#define KERN_MAXFILESPERPROC 29 /* int: max open files per proc */
#define KERN_MAXPROCPERUID 30 /* int: max processes per uid */
#define KERN_DUMPDEV 31 /* dev_t: device to dump on */
#define KERN_IPC 32 /* node: anything related to IPC */
#define KERN_DUMMY 33 /* unused */
#define KERN_PS_STRINGS 34 /* int: address of PS_STRINGS */
#define KERN_USRSTACK32 35 /* int: address of USRSTACK */
#define KERN_LOGSIGEXIT 36 /* int: do we log sigexit procs? */
#define KERN_SYMFILE 37 /* string: kernel symbol filename */
#define KERN_PROCARGS 38
/* 39 was KERN_PCSAMPLES... now deprecated */
#define KERN_NETBOOT 40 /* int: are we netbooted? 1=yes,0=no */
/* 41 was KERN_PANICINFO : panic UI information (deprecated) */
#define KERN_SYSV 42 /* node: System V IPC information */
#define KERN_AFFINITY 43 /* xxx */
#define KERN_TRANSLATE 44 /* xxx */
#define KERN_CLASSIC KERN_TRANSLATE /* XXX backwards compat */
#define KERN_EXEC 45 /* xxx */
#define KERN_CLASSICHANDLER KERN_EXEC /* XXX backwards compatibility */
#define KERN_AIOMAX 46 /* int: max aio requests */
#define KERN_AIOPROCMAX 47 /* int: max aio requests per process */
#define KERN_AIOTHREADS 48 /* int: max aio worker threads */
#ifdef __APPLE_API_UNSTABLE
#define KERN_PROCARGS2 49
#endif /* __APPLE_API_UNSTABLE */
#define KERN_COREFILE 50 /* string: corefile format string */
#define KERN_COREDUMP 51 /* int: whether to coredump at all */
#define KERN_SUGID_COREDUMP 52 /* int: whether to dump SUGID cores */
#define KERN_PROCDELAYTERM 53 /* int: set/reset current proc for delayed termination during shutdown */
#define KERN_SHREG_PRIVATIZABLE 54 /* int: can shared regions be privatized ? */
/* 55 was KERN_PROC_LOW_PRI_IO... now deprecated */
#define KERN_LOW_PRI_WINDOW 56 /* int: set/reset throttle window - milliseconds */
#define KERN_LOW_PRI_DELAY 57 /* int: set/reset throttle delay - milliseconds */
#define KERN_POSIX 58 /* node: posix tunables */
#define KERN_USRSTACK64 59 /* LP64 user stack query */
#define KERN_NX_PROTECTION 60 /* int: whether no-execute protection is enabled */
#define KERN_TFP 61 /* Task for pid settings */
#define KERN_PROCNAME 62 /* setup process program name(2*MAXCOMLEN) */
#define KERN_THALTSTACK 63 /* for compat with older x86 and does nothing */
#define KERN_SPECULATIVE_READS 64 /* int: whether speculative reads are disabled */
#define KERN_OSVERSION 65 /* for build number i.e. 9A127 */
#define KERN_SAFEBOOT 66 /* are we booted safe? */
/* 67 was KERN_LCTX (login context) */
#define KERN_RAGEVNODE 68
#define KERN_TTY 69 /* node: tty settings */
#define KERN_CHECKOPENEVT 70 /* spi: check the VOPENEVT flag on vnodes at open time */
#define KERN_THREADNAME 71 /* set/get thread name */
#define KERN_MAXID 72 /* number of valid kern ids */
/*
* Don't add any more sysctls like this. Instead, use the SYSCTL_*() macros
* and OID_AUTO. This will have the added benefit of not having to recompile
* sysctl(8) to pick up your changes.
*/