Filtering an NSArrayController in interface builder

Discussion in 'Mac Programming' started by oli364, Sep 11, 2010.

  1. oli364 macrumors newbie

    Sep 11, 2010
    I have (for example) a table with cars in. The cars each have a name, a color and a mileage.

    I can have a text field which displays the total mileage of all the cars using bindings in interface builder:

    Value - Bind To: Car Array Controller.arrangedObjects.@sum.mielage

    However, I would like separate boxes for the total mileage done by red cars and blues cars. I know i can code this using a predicate to filter the array eg:

    NSPredicate *bluePredicate = [NSPredicate predicateWithFormat:@"color like blue"];
    NSArray *blueCars = [[carArrayController arrangedObjects] filteredArrayUsingPredicate:bluePredicate];
    NSNumber *blueMileage = [blueFilteredArray valueForKeyPath:@"@sum.mileage"];

    But I don't want to have to do this and have to code IBOutlets for the text boxes. I want to do it purely in IB if possible.

    Any ideas??

    Cheers, Oli

Share This Page