// 从数组中检索 首字母相同的字符串
// {
// (abs ,abac),
// (b),
// (cdc, cfr)
// }
服务器接收参数
014-04-26 16:31:44.974 ZHRD[7389:60b] city {
hot = (
"\U70ed\U95e8-\U5e7f\U5dde\U5e02",
"\U70ed\U95e8-\U6df1\U5733\U5e02",
"\U70ed\U95e8-\U5317\U4eac\U5e02",
"\U70ed\U95e8-\U4e0a\U6d77\U5e02"
);
other = (
"C-\U957f\U6c99\U5e02",
"H-\U5408\U80a5\U5e02",
"H-\U676d\U5dde\U5e02",
"J-\U5409\U6797\U7701",
"K-\U6606\U660e\U5e02",
"L-\U4e3d\U6c5f\U5e02",
"M-\U7261\U4e39\U6c5f\U5e02",
"S-\U5341\U5830\U5e02",
"S-\U6c55\U5934\U5e02",
"T-\U5510\U5c71\U5e02",
"T-\U5929\U6c34\U5e02",
"T-\U5929\U6d25\U5e02",
"Y-\U5cb3\U9633\U5e02",
"Y-\U70df\U53f0\U5e02",
"Z-\U6dc4\U535a\U5e02",
"Z-\U91cd\U5e86\U5e02"
);
}
NSMutableDictionary *dicCity = [data JSONValue];
NSMutableArray *arrHot = [dicCity objectForKey:@"hot"];
NSMutableArray *arrOther = [dicCity objectForKey:@"other"];
NSLog(@"city %@",dicCity);
NSMutableDictionary *dicData = [[NSMutableDictionary alloc]initWithCapacity:1];
for (int i = 0; i < [arrOther count]; i++)
{
NSString *strOne = [arrOther objectAtIndex:i];
NSMutableArray *arrData = [dicData objectForKey:[strOne substringToIndex:1]];
if (!arrData)
{
arrData = [[NSMutableArray alloc]initWithCapacity:1];
[ArrShouzimu addObject:[strOne substringToIndex:1]];
}
[arrData addObject:strOne];
[dicData setObject:arrData forKey:[strOne substringToIndex:1]];
}
// 打印字典 dicData
2014-04-26 16:31:44.978 ZHRD[7389:60b] {
C = (
"C-\U957f\U6c99\U5e02"
);
H = (
"H-\U5408\U80a5\U5e02",
"H-\U676d\U5dde\U5e02"
);
J = (
"J-\U5409\U6797\U7701"
);
K = (
"K-\U6606\U660e\U5e02"
);
L = (
"L-\U4e3d\U6c5f\U5e02"
);
M = (
"M-\U7261\U4e39\U6c5f\U5e02"
);
S = (
"S-\U5341\U5830\U5e02",
"S-\U6c55\U5934\U5e02"
);
T = (
"T-\U5510\U5c71\U5e02",
"T-\U5929\U6c34\U5e02",
"T-\U5929\U6d25\U5e02"
);
Y = (
"Y-\U5cb3\U9633\U5e02",
"Y-\U70df\U53f0\U5e02"
);
Z = (
"Z-\U6dc4\U535a\U5e02",
"Z-\U91cd\U5e86\U5e02"
);