0

I am just learning KVO. This is my first time implementing it and I am getting rather confused trying to keep it all straight.

Right now I have a popupbutton that is connected to an arraycontroller whose content is supplied by a dictionary.

I have a second popupbutton with a filterpredicate set to the value of the first popupbutton's selection.

I need to add KVO to observe for changes in the first popupbutton's selection, and change the filterpredicate accordingly.

so far I have this..

 [nameController setContent:itemDictionaries];
 self.predicate  = [NSPredicate predicateWithFormat:@"item == %@", [[nameController selection] valueForKeyPath:@"item"]];

  [itemListController setFilterPredicate:self.predicate];

How can I add KVO to the popbutton's selection and subsequently update the value of the predicate?

1 Answers1

1

Solved it. Instead of KVO I just made that first popupbutton an action

- (IBAction)SelectionChanged:(id)sender 
{
    NSString *newItem = [[self.NamePopUp selectedItem] title];
    NSPredicate *newPredicate = [NSPredicate predicateWithFormat:@"item == %@", newItem];
    [itemListController setFilterPredicate:newPredicate];


}