If I want to display all the objects, I use the code below. But if I only want to display the objects where the value for the key “Favorite” = “Yes”, then what? Example of this would be great.
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle]
pathForResource:@"Objects" ofType:@"plist"];
sortedObjects = [[NSMutableArray alloc]initWithContentsOfFile:path];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [sortedObjects count];
}
Ps. The Property List is an array with dictionaries.
You need to create a new array, lets call it filtered, that you create by filtering sortedObjects, and use that to populate the table.