Basic array comparison algorithm

后端 未结 4 1564
半阙折子戏
半阙折子戏 2021-01-07 08:44

I\'m trying to follow the steps found here on comparing two arrays, and knowing when to create a new object, but I just don\'t understand how it works:

<
4条回答
  •  悲&欢浪女
    2021-01-07 09:25

    Something like this:

    NSArray *wholeList = [[NSArray alloc]initWithObjects:@"employee1", @"employee2", @"employee3", @"employee4", @"employee5",@"employee6", nil];
    NSArray *partialList = [[NSArray alloc]initWithObjects:@"employee2", @"employee13", @"employee7", nil];
    
    for (id employeeID in partialList)  //get one employee from the partialList
    {
        if (![wholeList containsObject:employeeID])  //check to see if it is in the wholeList
        {
            NSLog(@"This employee is not in the wholeList: %@", employeeID);
            // do create new employee object for this employeeID, whatever...
        }
    }
    

提交回复
热议问题