Check that the contents of one NSArray are all in another array

前端 未结 9 1764
说谎
说谎 2020-12-10 08:28

I have one NSArray with names in string objects like this:@[@\"john\", @\"smith\", @\"alex\", @\"louis\"], and I have another array that contains

9条回答
  •  囚心锁ツ
    2020-12-10 08:42

     NSArray *array1 = [NSArray arrayWithObjects:@"a", @"u", @"b", @"v", @"c", @"f", nil];
        NSMutableArray *mainArray = [NSMutableArray arrayWithObjects:@"a", @"u", @"I", @"G", @"O", @"W",@"Z",@"C",@"T", nil];
        int j=0;
        for(int i=0; i < mainArray.count; i++)
        {
            if (j < array1.count)
            {
                for( j=0; j <= i; j++)
                {
                    if([[mainArray objectAtIndex:i] isEqualToString:[array1 objectAtIndex:j]] )
                    {
                        NSLog(@"%@",[mainArray objectAtIndex:i]);
                    }
                }
            }
    
        }
    

提交回复
热议问题