tracking NSTextField changes
I am working on a project to add metadata to mp4's. I am tracking which fields have been altered, but the code looks "clunky" and not elegant to me. I hope someone can help me streamline this a bit.
Thank you alot,
Todd
- (void)controlTextDidChange:(NSNotification *)aNotification
{
if ([aNotification object] == directorField) [textChanges setObject:@"changed" forKey:@"directorChanges"];
if ([aNotification object] == writerField) [textChanges setObject:@"changed" forKey:@"writerChanges"];
if ([aNotification object] == castField) [textChanges setObject:@"changed" forKey:@"castChanges"];
if ([aNotification object] == producerField) [textChanges setObject:@"changed" forKey:@"producerChanges"];
if ([aNotification object] == typeField) [textChanges setObject:@"changed" forKey:@"typeChanges"];
if ([aNotification object] == showNameField) [textChanges setObject:@"changed" forKey:@"showNameChanges"];
if ([aNotification object] == episodeNameField) [textChanges setObject:@"changed" forKey:@"episodeNameChanges"];
if ([aNotification object] == airDateField) [textChanges setObject:@"changed" forKey:@"airDateChanges"];
if ([aNotification object] == episodeNumField) [textChanges setObject:@"changed" forKey:@"episodeNumChanges"];
if ([aNotification object] == seasonNumField) [textChanges setObject:@"changed" forKey:@"seasonNumChanges"];
if ([aNotification object] == theCompanyField) [textChanges setObject:@"changed" forKey:@"companyChanges"];
if ([aNotification object] == theRatingField) [textChanges setObject:@"changed" forKey:@"ratingChanges"];
if ([aNotification object] == albumField) [textChanges setObject:@"changed" forKey:@"albumChanges"];
if ([aNotification object] == thePlotField) [textChanges setObject:@"changed" forKey:@"plotChanges"];
if ([aNotification object] == ProductionCodeField) [textChanges setObject:@"changed" forKey:@"productionCodeChanges"];
}
I have switched from a NSMutableDictionary to an NSMutableArray, I really didn't need the keys.
- (void)controlTextDidChange:(NSNotification *)aNotification
{
if ([aNotification object] == directorField) [textChanges addObject:@"directorChanges"];
if ([aNotification object] == writerField) [textChanges addObject:@"writerChanges"];
if ([aNotification object] == castField) [textChanges addObject:@"castChanges"];
if ([aNotification object] == producerField) [textChanges addObject:@"producerChanges"];
if ([aNotification object] == typeField) [textChanges addObject:@"typeChanges"];
if ([aNotification object] == showNameField) [textChanges addObject:@"showNameChanges"];
if ([aNotification object] == episodeNameField) [textChanges addObject:@"episodeNameChanges"];
if ([aNotification object] == airDateField) [textChanges addObject:@"airDateChanges"];
if ([aNotification object] == episodeNumField) [textChanges addObject:@"episodeNumChanges"];
if ([aNotification object] == seasonNumField) [textChanges addObject:@"seasonNumChanges"];
if ([aNotification object] == theCompanyField) [textChanges addObject:@"companyChanges"];
if ([aNotification object] == theRatingField) [textChanges addObject:@"ratingChanges"];
if ([aNotification object] == albumField) [textChanges addObject:@"albumChanges"];
if ([aNotification object] == thePlotField) [textChanges addObject:@"plotChanges"];
if ([aNotification object] == ProductionCodeField) [textChanges addObject:@"productionCodeChanges"];
}