0
NSArray *details = [NSArray arrayWithObjects:@"name",@"age",@"gender",nil];
NSArray *ray1  = @[@"ray",@"23",@"male"];
NSArray *steve1  = @[@"steve",@"23",@"male"];
NSDictionary *ray = [NSDictionary dictionaryWithObjects:ray1 forKeys:details];
NSDictionary *steve = [NSDictionary dictionaryWithObjects:steve1 forKeys:details];
NSArray *register = @[ray,steve];

NSPredicate を使用してキーの値のみをフィルタリングする必要があります

4

1 に答える 1

1

これは、すべての辞書のキー「名前」の値を出力します

NSArray *details = [NSArray arrayWithObjects:@"name",@"age",@"gender",nil];
NSArray *ray1  = @[@"ray",@"23",@"male"];
NSArray *steve1  = @[@"steve",@"23",@"male"];
NSDictionary *ray = [NSDictionary dictionaryWithObjects:ray1 forKeys:details];
NSDictionary *steve = [NSDictionary dictionaryWithObjects:steve1 forKeys:details];
NSArray *reg = @[ray,steve];
NSPredicate *pr = [NSPredicate predicateWithValue:YES];
NSArray *ar = [[reg valueForKey:@"name"] filteredArrayUsingPredicate:pr];
NSLog(@"%@",ar);
于 2012-12-25T13:40:21.797 に答える