問題描述
我們正在開發一個 iPhone 應用程序,我需要為其讀取 iPhone 設置值(確切地說是設置->常規->日期和時間->自動設置"的狀態).有什么簡單/困難的方法可以找出這個值嗎?任何提示和技巧都將受到高度贊賞.
We are developing an iPhone application for which i need to read iPhone Settings value (precisely the status of 'Settings->General->Date & Time->Set Automatically'). Is there any way easy/difficult way to find out that value? Any tips and tricks will be highly appreciated.
推薦答案
你可以使用下面的代碼(我是通過檢查/var/mobile/Library/Preferences/的內容才發現的
我 iPad 上的目錄):
You can use the following code (I just found this out by examining the contents of the /var/mobile/Library/Preferences/
directory on my iPad):
NSDictionary *pref = [[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.timed"];
BOOL autotime = [[pref objectForKey:@"TMAutomaticTimeEnabled"] boolValue];
NSLog(@"Automatic time is %@", autotime ? @"enabled" : @"disabled");
這些密鑰未記錄在案,您可能不應該在 AppStore 應用程序中使用它們.不過,您可以在內部應用或越獄設備的軟件中安全地使用它們.
These keys are undocumented and you should probably not use them in an AppStore app. You can, however, safely use them in in-house apps or softwares for jailbroken devices.
這篇關于以編程方式讀取 iPhone 設置(精確設置 -> 常規 -> 日期和時間 -> 自動設置)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!