問(wèn)題描述
我們正在開(kāi)發(fā)一個(gè) iPhone 應(yīng)用程序,我需要為其讀取 iPhone 設(shè)置值(確切地說(shuō)是設(shè)置->常規(guī)->日期和時(shí)間->自動(dòng)設(shè)置"的狀態(tài)).有什么簡(jiǎn)單/困難的方法可以找出這個(gè)值嗎?任何提示和技巧都將受到高度贊賞.
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.
推薦答案
你可以使用下面的代碼(我是通過(guò)檢查/var/mobile/Library/Preferences/的內(nèi)容才發(fā)現(xiàn)的
我 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");
這些密鑰未記錄在案,您可能不應(yīng)該在 AppStore 應(yīng)用程序中使用它們.不過(guò),您可以在內(nèi)部應(yīng)用或越獄設(shè)備的軟件中安全地使用它們.
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.
這篇關(guān)于以編程方式讀取 iPhone 設(shè)置(精確設(shè)置 -> 常規(guī) -> 日期和時(shí)間 -> 自動(dòng)設(shè)置)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!