0

int 値を使用してこれらすべての配列を生成する方法はありますか? ...次のView Controllerでは約86個の配列があるため、コピー/貼り付けはあまりしたくありません。どんな助けでも大歓迎です。

ありがとう!!

NSPredicate *parentPredicate1 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"1"]; 
}];
NSPredicate *parentPredicate2 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"2"];
}];
NSPredicate *parentPredicate3 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"3"];
}];
NSPredicate *parentPredicate4 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"4"];
}];
NSPredicate *parentPredicate5 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"5"];
}];
NSPredicate *parentPredicate6 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"6"];
}];
NSPredicate *parentPredicate7 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"7"];
}];
NSPredicate *parentPredicate8 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"8"];
}];
NSPredicate *parentPredicate9 = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
    return [evaluatedObject[@"parent_id"] isEqual:@"9"];
}];

childID_1 = [parentArray filteredArrayUsingPredicate:parentPredicate1];
childID_2 = [parentArray filteredArrayUsingPredicate:parentPredicate2];
childID_3 = [parentArray filteredArrayUsingPredicate:parentPredicate3];
childID_4 = [parentArray filteredArrayUsingPredicate:parentPredicate4];
childID_5 = [parentArray filteredArrayUsingPredicate:parentPredicate5];
childID_6 = [parentArray filteredArrayUsingPredicate:parentPredicate6];
childID_7 = [parentArray filteredArrayUsingPredicate:parentPredicate7];
childID_8 = [parentArray filteredArrayUsingPredicate:parentPredicate8];
childID_9 = [parentArray filteredArrayUsingPredicate:parentPredicate9];

_allArrays = [[ NSMutableArray alloc] initWithObjects:childID_1, childID_2, childID_3, childID_4, childID_5, childID_6, childID_7, childID_8, childID_9, nil];

}

4

2 に答える 2