我是 iphone 开发的新手。我正在开发一个应用程序,我想解析这本字典并将电话号码存储在一个数组中。任何人都可以帮助..thanx 提前。这是我尝试过的代码。
-(void)filterContacts{
NSLog(@"I am here");
NSArray *letters = [[NSArray alloc] initWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil];
NSMutableArray* test=[[NSMutableArray alloc]init];
NSMutableArray* obj=[[NSMutableArray alloc]init];
NSLog(@" Data %@", dataArray);
for (int i=0; i<arrayLetters.count; i++) {
[test addObject:[[dataArray objectAtIndex:0] valueForKey:[arrayLetters objectAtIndex:i]]];
}
for (NSDictionary *dict2 in test) {
NSLog(@"%@",[dict2 valueForKey:@"telephone"]);
}
}
当我打印这个数组时,我得到了空值。我必须解析的数据如下所示。
2012-12-03 20:08:29.314(
)
2012-12-03 20:08:29.315 (
"1 (234) 560-789,20313561301"
)
2012-12-03 20:08:29.316 (
"(000) 000-0000"
)
DataArray (
{
"#" = (
);
A = (
);
B = (
);
C = (
);
D = (
);
E = (
);
F = (
);
G = (
);
H = (
);
I = (
);
J = (
);
K = (
{
letter = K;
name = kkkkkk;
rowSelected = "-1";
telephone = "1 (234) 560-789,20313561301";
telephoneSelected = "";
}
);
L = (
);
M = (
);
N = (
);
O = (
);
P = (
);
Q = (
);
R = (
{
letter = R;
name = RRRRR;
rowSelected = "-1";
telephone = "1234567890";
telephoneSelected = "1234567890";
}
);
S = (
);
T = (
);
U = (
);
V = (
);
W = (
);
X = (
);
Y = (
);
Z = (
);
}
)