Hi, I have maybe a simple question, but I cannot handle it.
- I have a "Location" of Modelclass class which contains an array with category identifier (12, 23, 56).
- Then I have an array with all the available category identifiers (1,2,3,4,5,6,7, ...)
- All of these categories have IDs that are displayed in the TableView and can choose or not.
- I show the marker hit on MapView (the annotation class is the location), which should be displayed based on the selection of filters in the mentioned TableView filter.
I need to implement the "Filter by category" function, which removes all the markers and adds them again, but only based on the selection in the list.
So, I need to compare the array with the filter identifier in the location model with the array with the entire filter identifier in the TableView. For this, I used the following function:
for (Location *currLocation in arrListOfLocationsNearby) {
for (NSString * currKatId in currLocation.arrKatIds) {
NSInteger intCurrKatId = [currKatId integerValue]; NSLog(@"Current KatId %@ id: %d \n", currLocation.strAdr, intCurrKatId); for (Filter *currFilter in [SDM getSharedDataManager].arrListOfFilterOptions) { if (currFilter.isSelected) { NSInteger intCurrFilterId = [currFilter.strAtt_id intValue]; NSLog(@"Current Filter %@ id: %d \n", currFilter.strAtt_text, intCurrFilterId); if ([currKatId intValue] == [currFilter.strAtt_id intValue]) { currLocation.isVisible = YES; }else { currLocation.isVisible = NO; } } }
}}
I know that this will be the most inefficient way to get around everything. I want to somehow use NSPredicate for this, but I have never used them before, and I can not find examples for my problem.
Any clues from you guys?
refers to m.
source share