Code of Interest in Main.m
for (int i = 0; i < 10; i++)
{
// Get a random number
NSUInteger randomIndex = random() % [employees count];
// Random employee chosen from employees array
BNREmployee *randomEmployee = [employees objectAtIndex:randomIndex];
// Remove all assets from randomEmployee
[randomEmployee removeAssetFromEmp:randomEmployee];
}
BNREmployee.m
- (void) removeAssetFromEmp:(BNREmployee *)emp
{
// Test if _assets is nil or zero
if (_assets == nil || _assets == 0)
{
NSLog(@"Employee ID:%u has no assets", self.employeeID);
return;
}
// When assets count reaches zero, then exit the loop
// i is not incremented in this loop
for (int i = 0; i < [_assets count];)
{
[_assets removeObjectAtIndex:i];
}