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:
<
Try something like this:
//Employee.h
@property (nonatomic) NSInteger ID;
@property (nonatomic, strong) NSString *name;
//Employee.m
@synthesize ID, name;
//Place where you put algorithm
#import "Employee.h"
------------------------
NSMutableArray *employeeIDs = [NSArray arrayWithObjects:[NSNumber numberWithInt:123], [NSNumber numberWithInt:456], [NSNumber numberWithInt:789], nil];
//Creates employee objects
Employee *employee1 = [[Employee alloc] init];
employee1.ID = 123;
employee1.name = @"John Smith";
Employee *employee2 = [[Employee alloc] init];
employee2.ID = 456;
employee2.name = @"Bob Day";
Employee *employee3 = [[Employee alloc] init];
employee3.ID = 789;
employee3.name = @"Steve Jobs";
NSMutableArray *employeesArray = [NSArray arrayWithObjects:employee1, employee2, employee3, nil];
for (int index = 0; index <= [employeeIDs count]; index++) {
for(id currentEmployee in employeesArray){
if(currentEmployee.ID != currentID){
Employee *newEmployee = [[Employee alloc] init];
newEmployee.name = [NSString stringWithFormat:@"Employee Name"];
newEmployee.ID = 384;
[employeeIDs addObject:[NSNumber numberWithInteger:newEmployee.ID]];
[employees addObject:newEmployee.name];
}
}
}
Hope this helps!