请教如何在存在NSDictionary的NSArray中查找
2014-12-08 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517192
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
NSArray *a1 = [NSArray arrayWithObjects:@"Boston", @"1111", nil];
NSArray *a2 = [NSArray arrayWithObjects:@"NewYork", @"2222", nil];
NSArray *a3 = [NSArray arrayWithObjects:@"Boston", @"3333", nil];
NSArray *a4 = [NSArray arrayWithObjects:@"Washington D.C", @"4444", nil];
NSArray *a5 = [NSArray arrayWithObjects:@"Los Angeles", @"5555", nil];
NSArray *arraysBefore = [NSArray arrayWithObjects:a1, a2, a3, a4, a5, nil];
NSMutableArray *arraysAfter = [NSMutableArray arrayWithCapacity:10];
for (NSArray *a in arraysBefore) {
if ([[a objectAtIndex:0] isEqualToString:@"Boston"]) {
[arraysAfter addObject:a];
}
}
NSLog(@"arrays after: %@", arraysAfter);
NSArray *a2 = [NSArray arrayWithObjects:@"NewYork", @"2222", nil];
NSArray *a3 = [NSArray arrayWithObjects:@"Boston", @"3333", nil];
NSArray *a4 = [NSArray arrayWithObjects:@"Washington D.C", @"4444", nil];
NSArray *a5 = [NSArray arrayWithObjects:@"Los Angeles", @"5555", nil];
NSArray *arraysBefore = [NSArray arrayWithObjects:a1, a2, a3, a4, a5, nil];
NSMutableArray *arraysAfter = [NSMutableArray arrayWithCapacity:10];
for (NSArray *a in arraysBefore) {
if ([[a objectAtIndex:0] isEqualToString:@"Boston"]) {
[arraysAfter addObject:a];
}
}
NSLog(@"arrays after: %@", arraysAfter);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询