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

BadWolf13

macrumors 6502
Original poster
Dec 17, 2009
271
0
I've got a tableView with a data source as an NSMutableArray. I want to filter information in this tableView by a user entered criteria, however, I can't find anything in NSTableView or NSTableView delegate that would allow me to do that. It seems the only way is to create a second array that contains the filtered(or non-filtered) results and use that as the data source. It seems like there should be an easy way to filter a TableView, given that it's probably done a lot, so am I missing something?
 

BadWolf13

macrumors 6502
Original poster
Dec 17, 2009
271
0
Unfortunately that's where I started. I found something in NSArrayController that's called Filtering, but doesn't really mean filtering in the same way that I do.
 

BadWolf13

macrumors 6502
Original poster
Dec 17, 2009
271
0
Ok, so I've got my tableView that's bound to an NSArrayController. Based on what I read, I created a method that returns an NSPredicate object which is then entered under the bindings screen for FilterPredicate of my NSArrayController. However, it's raising an exception whenever I run the program. This is the error message

2010-04-22 17:18:36.174 Inventory[2387:a0f] [<Part 0x100136fa0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key partsList.

This is the code for my NSPredicate method

Code:
-(NSPredicate *)tableFilter
{
	NSPredicate *aPredicate = [NSPredicate predicateWithFormat:
			@"ANY partsList.partNumber contains[c] %@", searchValue];

	return aPredicate;
}

Any thoughts on what I'm doing wrong here?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.