我有以下 PLIST,需要访问嵌套在字典中的 Assistant Identifier。问题是 Accounts 下的第一个键(以 4FD9E669... 开头)对于每个设备都是唯一的。如何在不知道字典键的情况下返回助手标识符?
这是我的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>Accounts</key>
<dict>
<key>4FD9E669-A5EA-4526-A6D2-0440858221A6</key>
<dict>
<key>Assistant Identifier</key>
<string>05483ADC-23E1-400E-83E8-F7365063F56F</string>
<key>Last Assistant Data Anchor</key>
<string>c1e3ad3c51d7fb962b29ca2deb4990c0f6ae8962</string>
<key>Speech Identifier</key>
<string>dcaf7c87-c023-456c-a200-7db8bd5e10f1</string>
<key>Validation Expiration</key>
<date>2012-07-17T22:37:37Z</date>
</dict>
</dict>
<key>Session Language</key>
<string>en-US</string>
</dict>
</plist>
如果 A.Identifier 已知,我已经尝试了以下方法......(这没有帮助)
NSString* filename = @"/var/mobile/Library/Preferences/com.apple.assistant.plist";
NSMutableDictionary* prefs = [[NSMutableDictionary alloc] initWithContentsOfFile:filename];
NSMutableDictionary* nestedPrefs = (NSMutableDictionary*)[prefs valueForKey:@"Accounts"];
NSMutableDictionary* aPrefs = (NSMutableDictionary*)[nestedPrefs valueForKey:@"4FD9E669-A5EA-4526-A6D2-0440858221A6"];
NSString* assistantPref = (NSString*)[aPrefs valueForKey:@"Assistant Identifier"];
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:@"Assistant Identifier" message:assistantPref delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[theAlert show];
[theAlert release];
请帮忙!谢谢你!