Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

John Baughman

macrumors regular
Original poster
Oct 27, 2003
100
0
Not understanding these two methods. I can see what they are supposed to do and they appear to be working, but I don't see that they are being called. The book says that we don't care about the add method. The remove method serves the function to set the entity "manager" in the Department table to nil if the employee being removed is the employee set as the manager in the Department table...

Code:
- (void)removeEmployeesObject:(Employee *)value
{
	NSLog(@"Dept %@ removing employee %@", [self deptName], [value fullName]);
	
	Employee *manager = [self manager];
	if(manager == value){
		[self setManager:nil];
	}
	
	NSSet *s = [NSSet setWithObjects:value];
	[self willChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:s];
	[[self primitiveValueForKey:@"employees"] removeObject:value];
	[self didChangeValueForKey:@"employees" withSetMutation:NSKeyValueMinusSetMutation usingObjects:s];
}

The NSLog event is never recorded and a trace put in the method is never hit. So how is this method being used? When I delete a manager the manager entity appears to be set to nil properly, but how?

Also why do we put these methods in Department.m and not Employee.m
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.