am calling a web service from my ios app , it returned dictionary of dictionaries,, like this
我从我的ios应用程序调用一个Web服务,它返回了字典字典,就像这样
<?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>1</key>
<dict>
<key>Business classification</key>
<string>a:2:{i:0;s:19:"Broker - Securities";i:1;s:18:"Financial Services";}</string>
<key>Cell phone</key>
<string>(2201258886</string>
<key>Company position</key>
<string>First Vice President - Wealth Management, CFP?</string>
<key>Country</key>
<string>UNITED STATES of AMERICA</string>
<key>Email</key>
<string>ravikirans@ms.com</string>
<key>Full name</key>
<string>llndrees</string>
<key>Office phone</key>
<string>(707) 571-5761</string>
<key>Rkkkty/name</key>
<string>Santkkka Roskka</string>
<key>State</key>
<string>Cakklifornia</string>
<key>user_id</key>
<string>1</string>
</dict>
<key>10</key>
<dict>
<key>Business classification</key>
<string>a:1:{i:0;s:16:"Business advisor";}</string>
<key>Cell phone</key>
<string>415-491-4102</string>
<key>Company position</key>
<string>Business Adviser</string>
<key>Country</key>
<string>UNITED STATES of AMERICA</string>
<key>Email</key>
<string>bygttfn@pacbgf</string>
<key>Full name</key>
<string>Biolas</string>
<key>Office phone</key>
<string>415+656165402</string>
<key>Rotuhuhame</key>
<string>Tiburon</string>
<key>State</key>
<string>Caliggggfornia</string>
<key>user_id</key>
<string>13</string>
</dict>
now i need to get all emails in a array how do i do this i tried this
现在我需要在阵列中获取所有电子邮件我如何做到这一点我试过这个
NSDictionary * Usernames = [[NSDictionary alloc]initWithContentsOfFile:strDocDirPath];
NSLog(@"%@",[Usernames valueForKey:@"Email"]);
but its returning nil,,can anybody help me out pls
但它的回归nil ,,任何人都可以帮助我
3 个解决方案
#1
1
You should try something like followings:
你应该尝试以下内容:
NSDictionary * Usernames = [[NSDictionary alloc]initWithContentsOfFile:strDocDirPath];
for (NSDictionary *item in Usernames)
{
NSLog(@"%@",[item valueForKey:@"Email"]);
}
#2
0
it should be a step by step process, try like this
它应该是一步一步的过程,试试这样
NSLog(@"%@",[[Usernames valueForKey:@"first key"] valueForKey:@"second key"] );
#3
0
Use this function of dictionary to enumerate and get all values of emails and store it into array.
使用此字典功能枚举并获取电子邮件的所有值并将其存储到数组中。
- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, BOOL *stop))block
- (void)enumerateKeysAndObjectsUsingBlock:(void(^)(id key,id obj,BOOL * stop))block
#1
1
You should try something like followings:
你应该尝试以下内容:
NSDictionary * Usernames = [[NSDictionary alloc]initWithContentsOfFile:strDocDirPath];
for (NSDictionary *item in Usernames)
{
NSLog(@"%@",[item valueForKey:@"Email"]);
}
#2
0
it should be a step by step process, try like this
它应该是一步一步的过程,试试这样
NSLog(@"%@",[[Usernames valueForKey:@"first key"] valueForKey:@"second key"] );
#3
0
Use this function of dictionary to enumerate and get all values of emails and store it into array.
使用此字典功能枚举并获取电子邮件的所有值并将其存储到数组中。
- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, BOOL *stop))block
- (void)enumerateKeysAndObjectsUsingBlock:(void(^)(id key,id obj,BOOL * stop))block