我正在用我的設備創建一個帶有theos的JB tweak。如何讀取plist字典,並將鍵(不是值)保存在另一個plist的數組字符串中?
我想讀的plist字典,如:
ASNPrefs.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ASNcenterEnabled</key>
<false/>
<key>ASNcornerEnabled</key>
<false/>
<key>ASNnoCenterEnabled</key>
<false/>
<key>ASNdepthSizeEnabled</key>
<false/>
</dict>
</plist>
和只寫密鑰作爲數組到像其他的plist:
ASNkeys.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ASNkeys</key>
<array>
<string>ASNcenterEnabled</string>
<string>ASNcornerEnabled</string>
<string>ASNnoCenterEnabled</string>
<string>ASNdepthSizeEnabled</string>
</array>
</dict>
</plist>
我創建了一個按鈕,這個動作,但沒有任何反應:
- DEFINED AT BEGINNING OF .MM:
#define prefs @"/User/Library/Preferences/ASNPrefs.plist"
#define asnKeysPath @"/User/Documents/asnKeys.plist"
#define asnKeysDict [[NSDictionary dictionaryWithContentsOfFile:asnKeysPath] objectForKey:@"keys"]
- IN THE IMPLEMENTATION:
-(void)ASNkeys {
NSDictionary *asnPrefs = [NSDictionary dictionaryWithContentsOfFile:prefs];
NSArray *allKeys = [prefs allKeys];
[allKeys writeToFile:asnKeysDict atomically:YES];
}
謝謝!
我不知道如何處理這個......建議?謝謝! – Olivier
好的!對不起......片刻.. – Olivier